public int CreateGroupForum(int portalId, int moduleId, int socialGroupId, int forumGroupId, string forumName, string forumDescription, bool isPrivate, string forumConfig) { var forumId = -1; try { var rc = new RoleController(); var forumsDb = new Data.Common(); var fgc = new ForumGroupController(); var gi = fgc.Groups_Get(moduleId, forumGroupId); var socialGroup = rc.GetRole(socialGroupId, portalId); var groupAdmin = socialGroupId.ToString() + ":0"; var groupMember = socialGroupId.ToString(); var ri = rc.GetRoleByName(portalId, "Administrators"); var permissionsId = forumsDb.CreatePermSet(ri.RoleID.ToString()); moduleId = gi.ModuleId; var fi = new Forum { ForumDesc = forumDescription, Active = true, ForumGroupId = forumGroupId, ForumID = -1, ForumName = forumName, Hidden = isPrivate, ModuleId = gi.ModuleId, ParentForumId = 0, PortalId = portalId, PermissionsId = gi.PermissionsId, SortOrder = 0, SocialGroupId = socialGroupId }; forumId = Forums_Save(portalId, fi, true, true); fi = GetForum(portalId, moduleId, forumId); fi.PermissionsId = permissionsId; Forums_Save(portalId, fi, false, false); var xDoc = new XmlDocument(); xDoc.LoadXml(forumConfig); var xRoot = xDoc.DocumentElement; if (xRoot != null) { var xSecList = xRoot.SelectSingleNode("//security[@type='groupadmin']"); string permSet; string secKey; if (xSecList != null) { foreach (XmlNode n in xSecList.ChildNodes) { secKey = n.Name; if (n.Attributes == null || n.Attributes["value"].Value != "true") { continue; } permSet = forumsDb.GetPermSet(permissionsId, secKey); permSet = Permissions.AddPermToSet(groupAdmin, 2, permSet); forumsDb.SavePermSet(permissionsId, secKey, permSet); } } xSecList = xRoot.SelectSingleNode("//security[@type='groupmember']"); if (xSecList != null) { foreach (XmlNode n in xSecList.ChildNodes) { secKey = n.Name; if (n.Attributes == null || n.Attributes["value"].Value != "true") { continue; } permSet = forumsDb.GetPermSet(permissionsId, secKey); permSet = Permissions.AddPermToSet(groupMember, 0, permSet); forumsDb.SavePermSet(permissionsId, secKey, permSet); } } if (socialGroup.IsPublic) { xSecList = xRoot.SelectSingleNode("//security[@type='registereduser']"); ri = rc.GetRoleByName(portalId, "Registered Users"); if (xSecList != null) { foreach (XmlNode n in xSecList.ChildNodes) { secKey = n.Name; if (n.Attributes == null || n.Attributes["value"].Value != "true") { continue; } permSet = forumsDb.GetPermSet(permissionsId, secKey); permSet = Permissions.AddPermToSet(ri.RoleID.ToString(), 0, permSet); forumsDb.SavePermSet(permissionsId, secKey, permSet); } } xSecList = xRoot.SelectSingleNode("//security[@type='anon']"); if (xSecList != null) { foreach (XmlNode n in xSecList.ChildNodes) { secKey = n.Name; if (n.Attributes == null || n.Attributes["value"].Value != "true") { continue; } permSet = forumsDb.GetPermSet(permissionsId, secKey); permSet = Permissions.AddPermToSet("-1", 0, permSet); forumsDb.SavePermSet(permissionsId, secKey, permSet); } } } } } catch (Exception ex) { } DataCache.CacheClear(moduleId + "fv"); return(forumId); }
public Task <HttpResponseMessage> UploadFile() { // This method uploads an attachment to a temporary directory and returns a JSON object containing information about the original file // including the temporary file name. When the post is saved/updated, the temporary file is moved to the appropriate attachment directory // Have to a reference to these variables as the internal reference isn't available. // in the async result. var request = Request; var portalSettings = PortalSettings; var userInfo = portalSettings.UserInfo; var forumUser = new UserController().GetUser(ActiveModule.PortalID, ActiveModule.ModuleID, userInfo.UserID); if (!request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable)); } const string uploadPath = "activeforums_Upload"; var folderManager = FolderManager.Instance; if (!folderManager.FolderExists(ActiveModule.PortalID, uploadPath)) { folderManager.AddFolder(ActiveModule.PortalID, uploadPath); } var folder = folderManager.GetFolder(ActiveModule.PortalID, uploadPath); var provider = new MultipartFormDataStreamProvider(folder.PhysicalPath); var task = request.Content.ReadAsMultipartAsync(provider).ContinueWith(t => { if (t.IsFaulted || t.IsCanceled) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } // Make sure a temp file was uploaded and that it exists var file = provider.FileData.FirstOrDefault(); if (file == null || string.IsNullOrWhiteSpace(file.LocalFileName) || !File.Exists(file.LocalFileName)) { return(request.CreateErrorResponse(HttpStatusCode.NoContent, "No File Found")); } // Get the file name without the full path var localFileName = Path.GetFileName(file.LocalFileName).TextOrEmpty(); // Check to make sure that a forum was specified and that the the user has upload permissions // This is only an initial check, it will be done again when the file is saved to a post. int forumId; if (!int.TryParse(provider.FormData["forumId"], out forumId)) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Specified")); } // Make sure that we can find the forum and that attachments are allowed var fc = new ForumController(); var forum = fc.Forums_Get(ActiveModule.PortalID, ActiveModule.ModuleID, forumId, userInfo.UserID, true, true, -1); if (forum == null || !forum.AllowAttach) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.BadRequest, "Forum Not Found")); } // Make sure the user has permissions to attach files if (forumUser == null || !Permissions.HasPerm(forum.Security.Attach, forumUser.UserRoles)) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Not Authorized")); } // Make sure that the file size does not exceed the limit (in KB) for the forum // Have to do this since content length is not available when using MultipartFormDataStreamProvider var di = new DirectoryInfo(folder.PhysicalPath); var fileSize = di.GetFiles(localFileName)[0].Length; var maxAllowedFileSize = (long)forum.AttachMaxSize * 1024; if ((forum.AttachMaxSize > 0) && (fileSize > maxAllowedFileSize)) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Exceeds Max File Size")); } // Get the original file name from the content disposition header var fileName = file.Headers.ContentDisposition.FileName.Replace("\"", ""); if (string.IsNullOrWhiteSpace(fileName)) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Invalid File")); } // Make sure we have an acceptable extension type. // Check against both the forum configuration and the host configuration var extension = Path.GetExtension(fileName).TextOrEmpty().Replace(".", string.Empty).ToLower(); var isForumAllowedExtension = string.IsNullOrWhiteSpace(forum.AttachTypeAllowed) || forum.AttachTypeAllowed.Replace(".", "").Split(',').Any(val => val == extension); if (string.IsNullOrEmpty(extension) || !isForumAllowedExtension || !Host.AllowedExtensionWhitelist.IsAllowedExtension(extension)) { File.Delete(file.LocalFileName); return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "File Type Not Allowed")); } const string newFileName = "{0}_{1}{2}"; var fileNameOnly = Path.GetFileNameWithoutExtension(fileName); var userFolder = folderManager.GetUserFolder(userInfo); var attachmentFolder = folderManager.GetFolder(userFolder.FolderID); var fileManager = FileManager.Instance; IFileInfo ufile = null; string sExt = Path.GetExtension(fileName); if (sExt.ToLower() == ".jpg" || sExt.ToLower() == ".bmp" || sExt.ToLower() == ".png" || sExt.ToLower() == ".jpeg") { var sExtOut = ".jpg"; ImageFormat imf, imfout = ImageFormat.Jpeg; Image img = Image.FromFile(file.LocalFileName); Image nimg; var maxWidth = forum.MaxAttachWidth; var maxHeight = forum.MaxAttachHeight; int imgWidth = img.Width; int imgHeight = img.Height; var ratioWidth = (double)imgWidth / maxWidth; var ratioHeight = (double)imgHeight / maxHeight; switch (sExt.ToLower()) { case ".png": { imf = ImageFormat.Png; if (!forum.ConvertingToJpegAllowed) { sExtOut = ".png"; imfout = ImageFormat.Png; } break; } case ".bmp": imf = ImageFormat.Bmp; break; default: imf = ImageFormat.Jpeg; break; } MemoryStream mst = new MemoryStream(); if (ratioWidth > 1 || ratioHeight > 1) { if (ratioWidth > ratioHeight) { imgWidth = maxWidth; imgHeight = (int)Math.Round(imgHeight / ratioWidth); } else if (ratioWidth < ratioHeight) { imgHeight = maxHeight; imgWidth = (int)Math.Round(imgWidth / ratioHeight); } else { imgWidth = maxWidth; imgHeight = maxHeight; } } Bitmap res = new Bitmap(imgWidth, imgHeight); using (Graphics gr = Graphics.FromImage(res)) { gr.Clear(Color.Transparent); gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; gr.DrawImage(img, new Rectangle(0, 0, imgWidth, imgHeight), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel); gr.Dispose(); } img.Dispose(); res.Save(mst, imfout); res.Dispose(); var index = 0; fileName = fileNameOnly + sExtOut; while (fileManager.FileExists(attachmentFolder, fileName)) { index++; fileName = string.Format(newFileName, fileNameOnly, index, sExtOut); } ufile = fileManager.AddFile(attachmentFolder, fileName, (Stream)mst); mst.Close(); } else { using (var fileStream = new FileStream(file.LocalFileName, FileMode.Open, FileAccess.Read)) { var index = 0; while (fileManager.FileExists(attachmentFolder, fileName)) { index++; fileName = string.Format(newFileName, fileNameOnly, index, sExt); } ufile = fileManager.AddFile(attachmentFolder, fileName, fileStream); } } // IE<=9 Hack - can't return application/json var mediaType = "application/json"; if (!request.Headers.Accept.Any(h => h.MediaType.Equals("application/json", StringComparison.OrdinalIgnoreCase))) { mediaType = "text/html"; } File.Delete(file.LocalFileName); if (ufile != null) { var result = new ClientAttachment() { FileId = ufile.FileId, ContentType = file.Headers.ContentType.MediaType, FileName = fileName, FileSize = ufile.Size, UploadId = localFileName, }; return(Request.CreateResponse(HttpStatusCode.Accepted, result, mediaType)); } else { return(request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "No File Found")); } }); return(task); }
public int Forums_Save(int portalId, Forum fi, bool isNew, bool useGroup) { var rc = new RoleController(); var db = new Data.Common(); var permissionsId = -1; if (useGroup && (string.IsNullOrEmpty(fi.ForumSettingsKey) || fi.PermissionsId == -1)) { var fc = new ForumGroupController(); var fg = fc.Groups_Get(fi.ModuleId, fi.ForumGroupId); if (fg != null) { fi.ForumSettingsKey = fg.GroupSettingsKey; //fi.ModuleId = fg.ModuleId fi.PermissionsId = fg.PermissionsId; } } else if (fi.PermissionsId <= 0 && useGroup == false) { var ri = rc.GetRoleByName(portalId, "Administrators"); if (ri != null) { fi.PermissionsId = db.CreatePermSet(ri.RoleID.ToString()); permissionsId = fi.PermissionsId; isNew = true; } if (fi.ForumID > 0 & !(string.IsNullOrEmpty(fi.ForumSettingsKey))) { if (fi.ForumSettingsKey.Contains("G:")) { fi.ForumSettingsKey = string.Empty; } } if (fi.ForumSettingsKey == "" && fi.ForumID > 0) { fi.ForumSettingsKey = "F:" + fi.ForumID; } } else if (useGroup == false && string.IsNullOrEmpty(fi.ForumSettingsKey) && fi.ForumID > 0) { fi.ForumSettingsKey = "F:" + fi.ForumID; } var forumId = Convert.ToInt32(DataProvider.Instance().Forum_Save(portalId, fi.ForumID, fi.ModuleId, fi.ForumGroupId, fi.ParentForumId, fi.ForumName, fi.ForumDesc, fi.SortOrder, fi.Active, fi.Hidden, fi.ForumSettingsKey, fi.PermissionsId, fi.PrefixURL, fi.SocialGroupId, fi.HasProperties)); if (String.IsNullOrEmpty(fi.ForumSettingsKey)) { fi.ForumSettingsKey = "F:" + forumId; } if (fi.ForumSettingsKey.Contains("G:")) { DataProvider.Instance().Forum_ConfigCleanUp(fi.ModuleId, "F:" + fi.ForumID, "F:" + fi.ForumID); } if (isNew && useGroup == false) { var moduleId = fi.ModuleId; Permissions.CreateDefaultSets(portalId, permissionsId); var sKey = "F:" + forumId.ToString(); Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicsTemplateId, "0"); Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicTemplateId, "0"); Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.TopicFormId, "0"); Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.ReplyFormId, "0"); Settings.SaveSetting(moduleId, sKey, ForumSettingKeys.AllowRSS, "false"); } // Clear the caches DataCache.CacheClear(string.Format(CacheKeys.ForumList, fi.ModuleId)); var cachekey = string.Format(forumInfoCacheKey, portalId, fi.ModuleId, forumId); DataCache.CacheClear(cachekey); return(forumId); }
public HttpResponseMessage CreateSplit(CreateSplitDTO dto) { if (dto.NewTopicId == dto.OldTopicId) { return(Request.CreateResponse(HttpStatusCode.OK)); } var portalSettings = PortalSettings; var userInfo = portalSettings.UserInfo; var forumUser = new UserController().GetUser(portalSettings.PortalId, ActiveModule.ModuleID, userInfo.UserID); var fc = new ForumController(); var forum_out = fc.Forums_Get(portalSettings.PortalId, ActiveModule.ModuleID, 0, forumUser.UserId, false, true, dto.OldTopicId); var forum_in = fc.GetForum(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId); if (forum_out != null && forum_in != null) { var perm = false; if (forum_out == forum_in) { perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles); } else { perm = Permissions.HasPerm(forum_out.Security.View, forumUser.UserRoles) && Permissions.HasPerm(forum_in.Security.View, forumUser.UserRoles); } var modSplit = Permissions.HasPerm(forum_out.Security.ModSplit, forumUser.UserRoles); if (perm && modSplit) { var tc = new TopicsController(); int topicId; if (dto.NewTopicId < 1) { var subject = Utilities.CleanString(portalSettings.PortalId, dto.Subject, false, EditorTypes.TEXTBOX, false, false, ActiveModule.ModuleID, string.Empty, false); var replies = dto.Replies.Split('|'); var rc = new DotNetNuke.Modules.ActiveForums.DAL2.ReplyController(); var firstReply = rc.Get(Convert.ToInt32(replies[0])); var cc = new ContentController(); var firstContent = cc.Get(firstReply.ContentId); topicId = tc.Topic_QuickCreate(portalSettings.PortalId, ActiveModule.ModuleID, dto.NewForumId, subject, string.Empty, firstContent.AuthorId, firstContent.AuthorName, true, Request.GetIPAddress()); tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, true); } else { topicId = dto.NewTopicId; tc.Replies_Split(dto.OldTopicId, topicId, dto.Replies, false); } } } return(Request.CreateResponse(HttpStatusCode.OK)); }
private void SaveQuickReply() { SettingsInfo ms = DataCache.MainSettings(ForumModuleId); int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileInfo upi = ForumUser.Profile; 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(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } if (!Request.IsAuthenticated) { if ((!ctlCaptcha.IsValid) || txtUserName.Value == "") { return; } } UserProfileInfo ui = new UserProfileInfo(); if (UserId > 0) { ui = ForumUser.Profile; } else { ui.TopicCount = 0; ui.ReplyCount = 0; ui.RewardPoints = 0; ui.IsMod = false; ui.TrustLevel = -1; } bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.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(); ReplyController rc = new ReplyController(); int ReplyId = -1; string sUsername = string.Empty; if (Request.IsAuthenticated) { switch (MainSettings.UserNameDisplay.ToUpperInvariant()) { case "USERNAME": sUsername = UserInfo.Username.Trim(' '); break; case "FULLNAME": sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' '); break; case "FIRSTNAME": sUsername = UserInfo.FirstName.Trim(' '); break; case "LASTNAME": sUsername = UserInfo.LastName.Trim(' '); break; case "DISPLAYNAME": sUsername = UserInfo.DisplayName.Trim(' '); break; default: sUsername = UserInfo.DisplayName; break; } } else { sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false); } //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject")) //If (UseFilter) Then // sSubject = Utilities.FilterWords(PortalId, ForumModuleId, ThemePath, sSubject) //End If string sBody = string.Empty; if (AllowHTML) { AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles)); } sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, 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 = Request.UserHostAddress; ReplyId = rc.Reply_Save(PortalId, ri); //Check if is subscribed string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); // Subscribe or unsubscribe if needed if (AllowSubscribe && UserId > 0) { var subscribe = Request.Params["chkSubscribe"] == "1"; var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId); if (subscribe != currentlySubscribed) { // Will need to update this to support multiple subscrition types later // Subscription_Update works as a toggle, so you only call it if you want to change the value. var sc = new SubscriptionController(); sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles); } } ControlUtils ctlUtils = new ControlUtils(); TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, -1, ReplyId, SocialGroupId); if (fullURL.Contains("~/") || Request.QueryString["asg"] != null) { fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); } if (fullURL.EndsWith("/")) { fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId; } if (isApproved) { //Send Subscriptions try { //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId); try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post Response.Redirect(fullURL, false); } else if (isApproved == false) { List <Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId); NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration"); string subject = Utilities.GetSharedResource("NotificationSubjectReply"); subject = subject.Replace("[DisplayName]", UserInfo.DisplayName); subject = subject.Replace("[TopicSubject]", ti.Content.Subject); string body = Utilities.GetSharedResource("NotificationBodyReply"); body = body.Replace("[Post]", sBody); string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId); Notification notification = new Notification(); notification.NotificationTypeID = notificationType.NotificationTypeId; notification.Subject = subject; notification.Body = body; notification.IncludeDismissAction = false; notification.SenderUserID = UserInfo.UserID; notification.Context = notificationKey; NotificationsController.Instance.SendNotification(notification, PortalId, null, mods); var @params = new List <string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; if (SocialGroupId > 0) { @params.Add("GroupId=" + SocialGroupId); } Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false); } else { //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //If MainSettings.UseShortUrls Then // fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //End If try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } Response.Redirect(fullURL, false); } //End If }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { //Me.AFModID = MID if (Request.IsAuthenticated) { btnSubmitLink.OnClientClick = "afQuickSubmit(); return false;"; AllowSubscribe = Permissions.HasPerm(ForumInfo.Security.Subscribe, ForumUser.UserRoles); } else { reqUserName.Enabled = true; reqUserName.Text = "<img src=\"" + ImagePath + "/images/warning.png\" />"; reqBody.Text = "<img src=\"" + ImagePath + "/images/warning.png\" />"; reqSecurityCode.Text = "<img src=\"" + ImagePath + "/images/warning.png\" />"; btnSubmitLink.Click += ambtnSubmit_Click; AllowSubscribe = false; } BoldText = Utilities.GetSharedResource("[RESX:Bold]"); ItalicsText = Utilities.GetSharedResource("[RESX:Italics]"); UnderlineText = Utilities.GetSharedResource("[RESX:Underline]"); QuoteText = Utilities.GetSharedResource("[RESX:Quote]"); BoldDesc = Utilities.GetSharedResource("[RESX:BoldDesc]"); ItalicsDesc = Utilities.GetSharedResource("[RESX:ItalicsDesc]"); UnderlineDesc = Utilities.GetSharedResource("[RESX:UnderlineDesc]"); QuoteDesc = Utilities.GetSharedResource("[RESX:QuoteDesc]"); CodeText = Utilities.GetSharedResource("[RESX:Code]"); CodeDesc = Utilities.GetSharedResource("[RESX:CodeDesc]"); ImageText = Utilities.GetSharedResource("[RESX:Image]"); ImageDesc = Utilities.GetSharedResource("[RESX:ImageDesc]"); if (UseFilter) { btnToolBar.Visible = true; } else { btnToolBar.Visible = false; } Subject = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + Subject; trSubscribe.Visible = AllowSubscribe; if (!Request.IsAuthenticated && CanReply) { trUsername.Visible = true; bolIsAnon = true; trCaptcha.Visible = true; } else { trUsername.Visible = false; trCaptcha.Visible = false; if (UserPrefTopicSubscribe || Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, this.UserId)) { SubscribedChecked = " checked=true"; } } if (Utilities.InputIsValid(Request.Form["txtBody"]) && Request.IsAuthenticated & ((!(string.IsNullOrEmpty(Request.Form["hidReply1"])) && string.IsNullOrEmpty(Request.Form["hidReply2"])) | Request.Browser.IsMobileDevice)) { SaveQuickReply(); } } catch (Exception exc) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } }
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 = ps.TimeZoneOffset; 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.AuthorizedRoles)) { //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 void GetControl(string view, string options) { try { if (!Page.IsPostBack) { plhLoader.Controls.Clear(); } ForumBase ctl = null; if (view.ToUpperInvariant() == "FORUMVIEW") { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else if (view.ToUpperInvariant() == "ADVANCED") { ctl = (ForumBase)(LoadControl("~/desktopmodules/activeforums/advanced.ascx")); } else if ((view.ToUpperInvariant() == Views.Topics.ToUpperInvariant()) || (view.ToUpperInvariant() == "topics".ToUpperInvariant())) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicsView()); } else if ((view.ToUpperInvariant() == Views.Topic.ToUpperInvariant()) || (view.ToUpperInvariant() == "topic".ToUpperInvariant())) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicView()); } else if (view.ToUpperInvariant() == "USERSETTINGS".ToUpperInvariant()) { string ctlPath = string.Empty; ctlPath = "~/DesktopModules/ActiveForums/controls/af_profile.ascx"; if (!(System.IO.File.Exists(Server.MapPath(ctlPath)))) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else { ctl = (ForumBase)(LoadControl(ctlPath)); } } else { // this is where af_post.ascx is used string ctlPath = string.Empty; ctlPath = "~/DesktopModules/ActiveForums/controls/af_" + view + ".ascx"; if (!(System.IO.File.Exists(Server.MapPath(ctlPath)))) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else { ctl = (ForumBase)(LoadControl(ctlPath)); } } if (ForumId > 0 & ForumInfo != null) { ctl.ForumInfo = ForumInfo; } ctl.ID = view; ctl.ForumId = ForumId; ctl.ForumModuleId = ForumModuleId; if (ForumTabId == -1) { ForumTabId = TabId; } ctl.ForumTabId = ForumTabId; ctl.ForumGroupId = ForumGroupId; ctl.DefaultForumViewTemplateId = DefaultForumViewTemplateId; ctl.DefaultTopicsViewTemplateId = DefaultTopicsViewTemplateId; ctl.DefaultTopicViewTemplateId = DefaultTopicViewTemplateId; ctl.UseTemplatePath = UseTemplatePath; ctl.TemplatePath = TemplatePath; ctl.ParentForumId = ParentForumId; if (string.IsNullOrEmpty(ForumIds)) { ForumIds = UserForumsList; } if (SocialGroupId > 0) { ForumController fc = new ForumController(); ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId); if (string.IsNullOrEmpty(ForumIds)) { RoleController rc = new RoleController(); RoleInfo role = rc.GetRole(SocialGroupId, PortalId); //Create new forum bool isPrivate = false; if (!role.IsPublic) { isPrivate = true; } Entities.Modules.ModuleController objModules = new Entities.Modules.ModuleController(); Hashtable htSettings = objModules.GetTabModuleSettings(TabModuleId); fc.CreateGroupForum(PortalId, ModuleId, SocialGroupId, Convert.ToInt32(htSettings["ForumGroupTemplate"].ToString()), role.RoleName + " Discussions", role.Description, isPrivate, htSettings["ForumConfig"].ToString()); ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId); } } ctl.ForumIds = ForumIds; ctl.SocialGroupId = SocialGroupId; //ctl.PostID = PostID ctl.ModuleConfiguration = this.ModuleConfiguration; if (!(options == string.Empty)) { ctl.Params = options; } ControlsConfig cc = new ControlsConfig(); cc.AppPath = Page.ResolveUrl("~/DesktopModules/ActiveForums/"); cc.ThemePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme + "/"); cc.TemplatePath = cc.ThemePath + "templates/"; cc.SiteId = PortalId; cc.PageId = TabId; cc.InstanceId = ModuleId; cc.User = ForumUser; cc.DefaultViewRoles = Permissions.GetRoleIds(this.ModuleConfiguration.AuthorizedViewRoles.Split(';'), PortalId); cc.AdminRoles = Permissions.GetRoleIds(this.ModuleConfiguration.AuthorizedEditRoles.Split(';'), PortalId); cc.ProfileLink = ""; //GetProfileLink() cc.MembersLink = ""; // GetMembersLink() this.ControlConfig = cc; ctl.ControlConfig = cc; LinkControls(ctl.Controls); if (!(plhLoader.Controls.Contains(ctl))) { plhLoader.Controls.Add(ctl); } string sOut = null; sOut = System.Environment.NewLine + "<!-- © 2004 - 2013 DNN Corp., All Rights Reserved -->" + System.Environment.NewLine; sOut += "<!-- Active Forums 5.0 -->" + System.Environment.NewLine; Literal lit = new Literal(); lit.Text = sOut; plhLoader.Controls.Add(lit); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }