private void btnSave_Click(object sender, System.EventArgs e) { if (UserId == UID || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser)) { UserProfileController upc = new UserProfileController(); UserController uc = new UserController(); UserProfileInfo upi = uc.GetUser(PortalId, ForumModuleId, UID).Profile; if (upi != null) { upi.PrefDefaultSort = Utilities.XSSFilter(drpPrefDefaultSort.SelectedItem.Value, true); upi.PrefPageSize = Convert.ToInt32(((Convert.ToInt32(nsPrefPageSize.Text) < 5) ? 5 : Convert.ToInt32(nsPrefPageSize.Text))); upi.PrefDefaultShowReplies = false; upi.PrefJumpLastPost = chkPrefJumpToLastPost.Checked; upi.PrefTopicSubscribe = chkPrefTopicSubscribe.Checked; upi.PrefSubscriptionType = SubscriptionTypes.Instant; upi.PrefUseAjax = false; upi.PrefBlockAvatars = chkPrefBlockAvatars.Checked; upi.PrefBlockSignatures = chkPrefBlockSignatures.Checked; if (MainSettings.AllowSignatures == 1 || MainSettings.AllowSignatures == 0) { upi.Signature = Utilities.XSSFilter(txtSignature.Text, true); upi.Signature = Utilities.StripHTMLTag(upi.Signature); upi.Signature = Utilities.HTMLEncode(upi.Signature); } else if (MainSettings.AllowSignatures == 2) { upi.Signature = Utilities.XSSFilter(txtSignature.Text, false); } upc.Profiles_Save(upi); Response.Redirect(NavigateUrl(TabId)); } } }
public User() { _userId = -1; _isSuperUser = false; _isAdmin = false; _profile = new UserProfileInfo(); _userRoles = Globals.DefaultAnonRoles + "|-1;||"; }
public UserProfileInfo Profiles_Get(int PortalId, int ModuleId, int UserId) { UserProfileInfo upi = null; DataSet ds = DataProvider.Instance().Profiles_Get(PortalId, ModuleId, UserId); if (ds.Tables.Count == 0) { //todo: UPI is always null? return(upi); } if (ds.Tables[0].Rows.Count > 0) { IDataReader dr; dr = ds.CreateDataReader(); upi = (UserProfileInfo)(CBO.FillObject(dr, typeof(UserProfileInfo))); } return(upi); }
private void cbAdmin_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth)) { UserProfileController upc = new UserProfileController(); UserController uc = new UserController(); UserProfileInfo upi = uc.GetUser(PortalId, ForumModuleId, UID).Profile; if (upi != null) { upi.RewardPoints = Convert.ToInt32(e.Parameters[1]); upi.UserCaption = e.Parameters[2].ToString(); upi.SignatureDisabled = Convert.ToBoolean(e.Parameters[3]); upi.AvatarDisabled = Convert.ToBoolean(e.Parameters[4]); upi.TrustLevel = Convert.ToInt32(e.Parameters[5]); upi.AdminWatch = Convert.ToBoolean(e.Parameters[6]); upi.AttachDisabled = Convert.ToBoolean(e.Parameters[7]); upc.Profiles_Save(upi); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); btnSave.Click += new System.EventHandler(btnSave_Click); nsPrefPageSize.Style.Add("float", "none"); nsPrefPageSize.EmptyMessageStyle.CssClass += "dnnformHint"; nsPrefPageSize.NumberFormat.DecimalDigits = 0; nsPrefPageSize.IncrementSettings.Step = 5; if (Request.QueryString["UserId"] == null) { UID = UserInfo.UserID; } else { UID = Convert.ToInt32(Request.QueryString["UserId"]); } //If UID <> UserInfo.UserID And Not UserInfo.IsInRole(PortalSettings.AdministratorRoleName) Then //End If UserProfileInfo ui = null; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null && !Page.IsPostBack) { drpPrefDefaultSort.SelectedIndex = drpPrefDefaultSort.Items.IndexOf(drpPrefDefaultSort.Items.FindByValue(ui.PrefDefaultSort.Trim())); nsPrefPageSize.Value = ui.PrefPageSize; chkPrefJumpToLastPost.Checked = ui.PrefJumpLastPost; chkPrefTopicSubscribe.Checked = ui.PrefTopicSubscribe; //chkPrefUseAjax.Checked = .PrefUseAjax chkPrefBlockAvatars.Checked = ui.PrefBlockAvatars; chkPrefBlockSignatures.Checked = ui.PrefBlockSignatures; txtSignature.Text = ui.Signature; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); UserProfileInfo ui = UserProfile; if (ui == null & UID > 0) { UserController up = new UserController(); ui = up.GetUser(PortalId, ForumModuleId, UID).Profile; } if (ui != null) { txtRewardPoints.Text = ui.RewardPoints.ToString(); txtUserCaption.Text = ui.UserCaption; chkDisableSignature.Checked = ui.SignatureDisabled; chkDisableAttachments.Checked = ui.AttachDisabled; chkDisableAvatar.Checked = ui.AvatarDisabled; chkMonitor.Checked = ui.AdminWatch; drpDefaultTrust.SelectedIndex = drpDefaultTrust.Items.IndexOf(drpDefaultTrust.Items.FindByValue(ui.TrustLevel.ToString())); txtRewardPoints.Attributes.Add("onkeypress", "return onlyNumbers(event);"); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); ServicesFramework.Instance.RequestAjaxAntiForgerySupport(); var oLink = new System.Web.UI.HtmlControls.HtmlGenericControl("link"); oLink.Attributes["rel"] = "stylesheet"; oLink.Attributes["type"] = "text/css"; oLink.Attributes["href"] = Page.ResolveUrl("~/DesktopModules/ActiveForums/scripts/calendar.css"); var oCSS = Page.FindControl("CSS"); if (oCSS != null) oCSS.Controls.Add(oLink); _fi = ForumInfo; _authorId = UserId; _canModEdit = Permissions.HasPerm(_fi.Security.ModEdit, ForumUser.UserRoles); _canModApprove = Permissions.HasPerm(_fi.Security.ModApprove, ForumUser.UserRoles); _canEdit = Permissions.HasPerm(_fi.Security.Edit, ForumUser.UserRoles); _canAttach = Permissions.HasPerm(_fi.Security.Attach, ForumUser.UserRoles); _canTrust = Permissions.HasPerm(_fi.Security.Trust, ForumUser.UserRoles); _canLock = Permissions.HasPerm(_fi.Security.Lock, ForumUser.UserRoles); _canPin = Permissions.HasPerm(_fi.Security.Pin, ForumUser.UserRoles); _canAnnounce = Permissions.HasPerm(_fi.Security.Announce, ForumUser.UserRoles); if (_fi == null) Response.Redirect(NavigateUrl(ForumTabId)); else if (Request.Params["action"] != null) { if (!_canEdit && (Request.Params["action"].ToLowerInvariant() == "te" || Request.Params["action"].ToLowerInvariant() == "re")) Response.Redirect(NavigateUrl(ForumTabId)); } if (CanCreate == false && CanReply == false) Response.Redirect(NavigateUrl(ForumTabId, "", "ctl=login") + "?returnurl=" + Server.UrlEncode(Request.RawUrl)); if (UserId > 0) _ui = ForumUser.Profile; else { _ui.TopicCount = 0; _ui.ReplyCount = 0; _ui.RewardPoints = 0; _ui.IsMod = false; _ui.TrustLevel = -1; } _userIsTrusted = Utilities.IsTrusted((int)_fi.DefaultTrustValue, _ui.TrustLevel, _canTrust, _fi.AutoTrustLevel, _ui.PostCount); Spinner = Page.ResolveUrl("~/DesktopModules/activeforums/themes/" + MainSettings.Theme + "/images/loading.gif"); _isApproved = !_fi.IsModerated || _userIsTrusted || _canModApprove; var myTheme = MainSettings.Theme; _themePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + myTheme); ctlForm.ID = "ctlForm"; ctlForm.PostButton.ImageUrl = _themePath + "/images/save32.png"; ctlForm.PostButton.ImageLocation = "TOP"; ctlForm.PostButton.Height = Unit.Pixel(50); ctlForm.PostButton.Width = Unit.Pixel(50); ctlForm.PostButton.ClientSideScript = "amPostback();"; ctlForm.PostButton.PostBack = false; ctlForm.AttachmentsClientId = hidAttachments.ClientID; // TODO: Make sure this check happens on submit //if (_canAttach && _fi.AllowAttach) {} ctlForm.CancelButton.ImageUrl = _themePath + "/images/cancel32.png"; ctlForm.CancelButton.ImageLocation = "TOP"; ctlForm.CancelButton.PostBack = false; ctlForm.CancelButton.ClientSideScript = "javascript:history.go(-1);"; ctlForm.CancelButton.Confirm = true; ctlForm.CancelButton.Height = Unit.Pixel(50); ctlForm.CancelButton.Width = Unit.Pixel(50); ctlForm.CancelButton.ConfirmMessage = GetSharedResource("[RESX:ConfirmCancel]"); ctlForm.ModuleConfiguration = ModuleConfiguration; ctlForm.Subscribe = UserPrefTopicSubscribe; if (_fi.AllowHTML) { _allowHTML = IsHtmlPermitted(_fi.EditorPermittedUsers, _userIsTrusted, _canModEdit); } ctlForm.AllowHTML = _allowHTML; if (_allowHTML) { _editorType = _fi.EditorType; } else { _editorType = EditorTypes.TEXTBOX; } if (Request.Browser.IsMobileDevice) { _editorType = EditorTypes.TEXTBOX; _allowHTML = false; } ctlForm.EditorType = _editorType; ctlForm.ForumInfo = _fi; ctlForm.RequireCaptcha = true; switch (_editorType) { case EditorTypes.TEXTBOX: Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/text_editor.js")); break; case EditorTypes.ACTIVEEDITOR: Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/active_editor.js")); break; default: { var prov = ProviderConfiguration.GetProviderConfiguration("htmlEditor"); if (prov.DefaultProvider.ToLowerInvariant().Contains("telerik") | prov.DefaultProvider.ToLowerInvariant().Contains("radeditor")) { Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/telerik_editor.js")); } else if (prov.DefaultProvider.Contains("CKHtmlEditorProvider")) { Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/ck_editor.js")); } else if (prov.DefaultProvider.Contains("FckHtmlEditorProvider")) { Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/fck_editor.js")); } else { Page.ClientScript.RegisterClientScriptInclude("afeditor", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/other_editor.js")); } } break; } if (Request.Params["action"] != null) { switch (Request.Params["action"].ToLowerInvariant()) { case "te": //Topic Edit if (_canModEdit || (_canEdit && Request.IsAuthenticated)) { _isEdit = true; PrepareTopic(); LoadTopic(); } break; case "re": //Reply Edit if (_canModEdit || (_canEdit && Request.IsAuthenticated)) { _isEdit = true; PrepareReply(); LoadReply(); } break; case "reply": if (CanReply) { PrepareReply(); } break; case "new": if (CanCreate) { PrepareTopic(); } break; default: if (CanCreate) { PrepareTopic(); } break; } } else { if (QuoteId == 0 && ReplyId == 0 && TopicId == -1 && CanCreate) { PrepareTopic(); } else if ((QuoteId > 0 | ReplyId > 0 | TopicId > 0) && CanReply) { PrepareReply(); } } if (_isEdit && !Request.IsAuthenticated) { Response.Redirect(NavigateUrl(ForumTabId)); } PrepareAttachments(_contentId); ctlForm.ContentId = _contentId; ctlForm.AuthorId = _authorId; plhContent.Controls.Add(ctlForm); EditorClientId = ctlForm.ClientID; ctlForm.BubbleClick += ctlForm_Click; cbPreview.CallbackEvent += cbPreview_Callback; //Page.ClientScript.RegisterClientScriptInclude("aftags", Page.ResolveUrl("~/desktopmodules/activeforums/scripts/jquery.tokeninput.js")) }
// KR - added caching to profiles to skip the DB hit public UserProfileInfo Profiles_Get(int SiteId, int InstanceId, int UserId) { string cachekey = string.Format("AF-prof-{0}-{1}-{2}", UserId, SiteId, InstanceId); DataTable dt = null; UserProfileInfo upi = null; Data.Profiles db = new Data.Profiles(); PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings(); if (SiteId == -1) { SiteId = _portalSettings.PortalId; } // see if it's in cache already object data = DataCache.CacheRetrieve(cachekey); if (data != null) { dt = (DataTable)data; } else { dt = DotNetNuke.Common.Globals.ConvertDataReaderToDataTable(db.Profiles_Get(SiteId, -1, UserId)); DataCache.CacheStore(cachekey, dt); } foreach (DataRow row in dt.Rows) { upi = new UserProfileInfo(); upi.PortalId = SiteId; upi.UserID = UserId; upi.ModuleId = -1; upi.AdminWatch = bool.Parse(row["AdminWatch"].ToString()); upi.AnswerCount = int.Parse(row["AnswerCount"].ToString()); upi.AOL = row["AOL"].ToString(); upi.AttachDisabled = bool.Parse(row["AttachDisabled"].ToString()); upi.Avatar = row["Avatar"].ToString(); upi.AvatarDisabled = bool.Parse(row["AvatarDisabled"].ToString()); upi.AvatarType = (AvatarTypes)(int.Parse(row["AvatarType"].ToString())); upi.Badges = row["Badges"].ToString(); //.Bio = dr("Bio").ToString upi.DateLastActivity = DateTime.Parse(row["DateLastActivity"].ToString()); upi.DateLastPost = DateTime.Parse(row["DateLastPost"].ToString()); upi.ForumsAllowed = string.Empty; upi.ICQ = row["ICQ"].ToString(); upi.Interests = row["Interests"].ToString(); upi.IsUserOnline = Convert.ToBoolean(((int.Parse(row["IsUserOnline"].ToString()) == 1) ? 1 : 0)); upi.Location = row["Location"].ToString(); upi.MSN = row["MSN"].ToString(); upi.Occupation = row["Occupation"].ToString(); upi.PrefBlockAvatars = bool.Parse(row["PrefBlockAvatars"].ToString()); upi.PrefBlockSignatures = bool.Parse(row["PrefBlockSignatures"].ToString()); upi.PrefDefaultShowReplies = bool.Parse(row["PrefDefaultShowReplies"].ToString()); upi.PrefDefaultSort = row["PrefDefaultSort"].ToString(); upi.PrefJumpLastPost = bool.Parse(row["PrefJumpLastPost"].ToString()); upi.PrefPageSize = int.Parse(row["PrefPageSize"].ToString()); upi.PrefSubscriptionType = (SubscriptionTypes)(int.Parse(row["PrefSubscriptionType"].ToString())); upi.PrefTopicSubscribe = bool.Parse(row["PrefTopicSubscribe"].ToString()); upi.PrefUseAjax = bool.Parse(row["PrefUseAjax"].ToString()); upi.ProfileId = int.Parse(row["ProfileId"].ToString()); upi.ReplyCount = int.Parse(row["ReplyCount"].ToString()); upi.RewardPoints = int.Parse(row["RewardPoints"].ToString()); upi.Signature = row["Signature"].ToString(); upi.SignatureDisabled = bool.Parse(row["SignatureDisabled"].ToString()); upi.TopicCount = int.Parse(row["TopicCount"].ToString()); upi.TrustLevel = int.Parse(row["TrustLevel"].ToString()); upi.UserCaption = row["UserCaption"].ToString(); upi.ViewCount = int.Parse(row["ViewCount"].ToString()); upi.WebSite = row["WebSite"].ToString(); upi.Yahoo = row["Yahoo"].ToString(); upi.DateCreated = DateTime.Parse(row["DateCreated"].ToString()); } return upi; }
public void Profiles_Save(UserProfileInfo ui) { DataProvider.Instance().Profiles_Save(ui.PortalId, ui.ModuleId, ui.UserID, ui.TopicCount, ui.ReplyCount, ui.ViewCount, ui.AnswerCount, ui.RewardPoints, ui.UserCaption, ui.Signature, ui.SignatureDisabled, ui.TrustLevel, ui.AdminWatch, ui.AttachDisabled, ui.Avatar, (int)ui.AvatarType, ui.AvatarDisabled, ui.PrefDefaultSort, ui.PrefDefaultShowReplies, ui.PrefJumpLastPost, ui.PrefTopicSubscribe, (int)ui.PrefSubscriptionType, ui.PrefUseAjax, ui.PrefBlockAvatars, ui.PrefBlockSignatures, ui.PrefPageSize, ui.Yahoo, ui.MSN, ui.ICQ, ui.AOL, ui.Occupation, ui.Location, ui.Interests, ui.WebSite, ui.Badges); // KR - clear cache when updated Profiles_ClearCache(ui.UserID); }
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 }
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 }
public void Profiles_Save(UserProfileInfo ui) { DataProvider.Instance().Profiles_Save(ui.PortalId, ui.ModuleId, ui.UserID, ui.TopicCount, ui.ReplyCount, ui.ViewCount, ui.AnswerCount, ui.RewardPoints, ui.UserCaption, ui.Signature, ui.SignatureDisabled, ui.TrustLevel, ui.AdminWatch, ui.AttachDisabled, ui.Avatar, (int)ui.AvatarType, ui.AvatarDisabled, ui.PrefDefaultSort, ui.PrefDefaultShowReplies, ui.PrefJumpLastPost, ui.PrefTopicSubscribe, (int)ui.PrefSubscriptionType, ui.PrefUseAjax, ui.PrefBlockAvatars, ui.PrefBlockSignatures, ui.PrefPageSize, ui.Yahoo, ui.MSN, ui.ICQ, ui.AOL, ui.Occupation, ui.Location, ui.Interests, ui.WebSite, ui.Badges); // KR - clear cache when updated DataCache.CacheClearPrefix(string.Format("AF-prof-{0}", ui.UserID)); }
// KR - added caching to profiles to skip the DB hit public UserProfileInfo Profiles_Get(int SiteId, int InstanceId, int UserId) { string cachekey = string.Format("AF-prof-{0}-{1}-{2}", UserId, SiteId, InstanceId); DataTable dt = null; UserProfileInfo upi = null; Data.Profiles db = new Data.Profiles(); PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings(); if (SiteId == -1) { SiteId = _portalSettings.PortalId; } // see if it's in cache already object data = DataCache.CacheRetrieve(cachekey); if (data != null) { dt = (DataTable)data; } else { dt = DotNetNuke.Common.Globals.ConvertDataReaderToDataTable(db.Profiles_Get(SiteId, -1, UserId)); DataCache.CacheStore(cachekey, dt); } foreach (DataRow row in dt.Rows) { upi = new UserProfileInfo(); upi.PortalId = SiteId; upi.UserID = UserId; upi.ModuleId = -1; upi.AdminWatch = bool.Parse(row["AdminWatch"].ToString()); upi.AnswerCount = int.Parse(row["AnswerCount"].ToString()); upi.AOL = row["AOL"].ToString(); upi.AttachDisabled = bool.Parse(row["AttachDisabled"].ToString()); upi.Avatar = row["Avatar"].ToString(); upi.AvatarDisabled = bool.Parse(row["AvatarDisabled"].ToString()); upi.AvatarType = (AvatarTypes)(int.Parse(row["AvatarType"].ToString())); upi.Badges = row["Badges"].ToString(); //.Bio = dr("Bio").ToString upi.DateLastActivity = DateTime.Parse(row["DateLastActivity"].ToString()); upi.DateLastPost = DateTime.Parse(row["DateLastPost"].ToString()); upi.ForumsAllowed = string.Empty; upi.ICQ = row["ICQ"].ToString(); upi.Interests = row["Interests"].ToString(); upi.IsUserOnline = Convert.ToBoolean(((int.Parse(row["IsUserOnline"].ToString()) == 1) ? 1 : 0)); upi.Location = row["Location"].ToString(); upi.MSN = row["MSN"].ToString(); upi.Occupation = row["Occupation"].ToString(); upi.PrefBlockAvatars = bool.Parse(row["PrefBlockAvatars"].ToString()); upi.PrefBlockSignatures = bool.Parse(row["PrefBlockSignatures"].ToString()); upi.PrefDefaultShowReplies = bool.Parse(row["PrefDefaultShowReplies"].ToString()); upi.PrefDefaultSort = row["PrefDefaultSort"].ToString(); upi.PrefJumpLastPost = bool.Parse(row["PrefJumpLastPost"].ToString()); upi.PrefPageSize = int.Parse(row["PrefPageSize"].ToString()); upi.PrefSubscriptionType = (SubscriptionTypes)(int.Parse(row["PrefSubscriptionType"].ToString())); upi.PrefTopicSubscribe = bool.Parse(row["PrefTopicSubscribe"].ToString()); upi.PrefUseAjax = bool.Parse(row["PrefUseAjax"].ToString()); upi.ProfileId = int.Parse(row["ProfileId"].ToString()); upi.ReplyCount = int.Parse(row["ReplyCount"].ToString()); upi.RewardPoints = int.Parse(row["RewardPoints"].ToString()); upi.Signature = row["Signature"].ToString(); upi.SignatureDisabled = bool.Parse(row["SignatureDisabled"].ToString()); upi.TopicCount = int.Parse(row["TopicCount"].ToString()); upi.TrustLevel = int.Parse(row["TrustLevel"].ToString()); upi.UserCaption = row["UserCaption"].ToString(); upi.ViewCount = int.Parse(row["ViewCount"].ToString()); upi.WebSite = row["WebSite"].ToString(); upi.Yahoo = row["Yahoo"].ToString(); upi.DateCreated = DateTime.Parse(row["DateCreated"].ToString()); } return(upi); }