/// <summary> /// Handles click on save button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { // go through all roles displayed on page for (int i = 0; i < this.UserGroups.Items.Count; i++) { // get current item RepeaterItem item = this.UserGroups.Items[i]; // get role ID from it int roleID = int.Parse(((Label)item.FindControl("GroupID")).Text); // get role name string roleName = string.Empty; using (DataTable dt = DB.group_list(this.PageContext.PageBoardID, roleID)) { foreach (DataRow row in dt.Rows) { roleName = (string)row["Name"]; } } // is user supposed to be in that role? bool isChecked = ((CheckBox)item.FindControl("GroupMember")).Checked; // save user in role DB.usergroup_save(this.CurrentUserID, roleID, isChecked); // update roles if this user isn't the guest if (!UserMembershipHelper.IsGuestUser(this.CurrentUserID)) { // get user's name string userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID); // add/remove user from roles in membership provider if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.AddUserToRole(userName, roleName); } else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.RemoveUserFromRole(userName, roleName); } // Clearing cache with old permisssions data... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.CurrentUserID))); } } // update forum moderators cache just in case something was changed... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); // clear the cache for this user... UserMembershipHelper.ClearCacheForUserId(this.CurrentUserID); this.BindData(); }
/// <summary> /// Handles click on save button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { // go through all roles displayed on page for (var i = 0; i < this.UserGroups.Items.Count; i++) { // get current item var item = this.UserGroups.Items[i]; // get role ID from it var roleID = int.Parse(((Label)item.FindControl("GroupID")).Text); // get role name var roleName = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID, groupId: roleID) .FirstOrDefault().Name; // is user supposed to be in that role? var isChecked = ((CheckBox)item.FindControl("GroupMember")).Checked; // save user in role this.Get <IDbFunction>().Query.usergroup_save(this.CurrentUserID, roleID, isChecked); // empty out access table(s) this.GetRepository <Active>().DeleteAll(); this.GetRepository <ActiveAccess>().DeleteAll(); // update roles if this user isn't the guest if (UserMembershipHelper.IsGuestUser(this.CurrentUserID)) { continue; } // get user's name var userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID); // add/remove user from roles in membership provider if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.AddUserToRole(userName, roleName); } else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.RemoveUserFromRole(userName, roleName); } // Clearing cache with old permisssions data... this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(this.CurrentUserID)); } // update forum moderators cache just in case something was changed... this.Get <IDataCache>().Remove(Constants.Cache.ForumModerators); // clear the cache for this user... this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID)); this.BindData(); }
/// <summary> /// The render. /// </summary> /// <param name="writer"> /// The writer. /// </param> protected override void Render(HtmlTextWriter writer) { var userName = Parameters["inner"]; if (userName.IsNotSet() || userName.Length > 50) { return; } var userId = this.Get <IUserDisplayName>().GetId(userName.Trim()); if (userId.HasValue) { var stringBuilder = new StringBuilder(); var userLink = new UserLink { UserID = (int)userId, CssClass = "UserLinkBBCode", BlankTarget = true, ID = "UserLinkBBCodeFor{0}".FormatWith(userId) }; var showOnlineStatusImage = this.Get <YafBoardSettings>().ShowUserOnlineStatus&& !UserMembershipHelper.IsGuestUser(userId); var onlineStatusImage = new OnlineStatusImage { ID = "OnlineStatusImage", Style = "vertical-align: bottom", UserID = (int)userId }; stringBuilder.AppendLine("<!-- BEGIN userlink -->"); stringBuilder.AppendLine(@"<span class=""userLinkContainer"">"); stringBuilder.AppendLine(userLink.RenderToString()); if (showOnlineStatusImage) { stringBuilder.AppendLine(onlineStatusImage.RenderToString()); } stringBuilder.AppendLine("</span>"); stringBuilder.AppendLine("<!-- END userlink -->"); writer.Write(stringBuilder.ToString()); } else { writer.Write(this.HtmlEncode(userName)); } }
/// <summary> /// Handles click event of Update button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Update_Click([NotNull] object sender, [NotNull] EventArgs e) { // no user was specified if (this.UserName.Text.Length <= 0) { this.PageContext.AddLoadMessage(this.GetText("NO_SUCH_USER"), MessageTypes.warning); return; } // if we choose user from drop down, set selected value to text box if (this.ToList.Visible) { this.UserName.Text = this.ToList.SelectedItem.Text; } // we need to verify user exists var userId = this.Get <IUserDisplayName>().GetId(this.UserName.Text.Trim()); // there is no such user or reference is ambiguous if (!userId.HasValue) { this.PageContext.AddLoadMessage(this.GetText("NO_SUCH_USER"), MessageTypes.warning); return; } if (UserMembershipHelper.IsGuestUser(userId)) { this.PageContext.AddLoadMessage(this.GetText("NOT_GUEST"), MessageTypes.warning); return; } // save permission this.GetRepository <UserForum>().Save( userId.Value, this.PageContext.PageForumID, this.AccessMaskID.SelectedValue.ToType <int>()); // clear moderators cache this.Get <IDataCache>().Remove(Constants.Cache.ForumModerators); this.Get <IDataCache>().Remove(Constants.Cache.BoardModerators); // redirect to forum moderation page BuildLink.Redirect(ForumPages.Moderating, "f={0}", this.PageContext.PageForumID); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender([NotNull] EventArgs e) { CodeContracts.VerifyNotNull(this.MessageFlags, "MessageFlags"); this.MessageID = this.CurrentMessage.ID; if (!this.MessageFlags.IsDeleted) { // populate DisplayUserID if (!UserMembershipHelper.IsGuestUser(this.CurrentMessage.UserID)) { this.DisplayUserID = this.CurrentMessage.UserID; } this.IsAlt = this.IsAltMessage; this.RowColSpan = this.ColSpan; if (this.ShowAttachments) { if (this.CurrentMessage.HasAttachments ?? false) { // add attached files control... var attached = new MessageAttached { MessageID = this.CurrentMessage.ID }; if (this.CurrentMessage.UserID > 0 && YafContext.Current.Get <YafBoardSettings>().EnableDisplayName) { attached.UserName = UserMembershipHelper.GetDisplayNameFromID(this.CurrentMessage.UserID); } else { attached.UserName = this.CurrentMessage.UserName; } this.Controls.Add(attached); } } } base.OnPreRender(e); }
/// <summary> /// Handles click event of Update button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Update_Click(object sender, EventArgs e) { // no user was specified if (this.UserName.Text.Length <= 0) { PageContext.AddLoadMessage(GetText("NO_SUCH_USER")); return; } // if we choose user from drop down, set selected value to text box if (this.ToList.Visible) { this.UserName.Text = this.ToList.SelectedItem.Text; } // we need to verify user exists var userId = PageContext.UserDisplayName.GetId(this.UserName.Text.Trim()); // there is no such user or reference is ambiugous if (!userId.HasValue) { PageContext.AddLoadMessage(GetText("NO_SUCH_USER")); return; } else if (UserMembershipHelper.IsGuestUser(userId)) { PageContext.AddLoadMessage(GetText("NOT_GUEST")); return; } // save permission DB.userforum_save(userId.Value, PageContext.PageForumID, this.AccessMaskID.SelectedValue); // redirect to forum moderation page YafBuildLink.Redirect(ForumPages.moderate, "f={0}", PageContext.PageForumID); // clear moderatorss cache PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnPreRender([NotNull] EventArgs e) { if (this.DataRow != null && !this.MessageFlags.IsDeleted) { // populate DisplayUserID if (!UserMembershipHelper.IsGuestUser(this.DataRow["UserID"])) { this.DisplayUserID = this.DataRow["UserID"].ToType <int>(); } this.IsAlt = this.IsAltMessage; this.RowColSpan = this.ColSpan; if (this.ShowAttachments && long.Parse(this.DataRow["HasAttachments"].ToString()) > 0) { // add attached files control... var attached = new MessageAttached { MessageID = this.DataRow["MessageID"].ToType <int>() }; if (this.DataRow["UserID"] != DBNull.Value && YafContext.Current.Get <YafBoardSettings>().EnableDisplayName) { attached.UserName = UserMembershipHelper.GetDisplayNameFromID(this.DataRow["UserID"].ToType <long>()); } else { attached.UserName = this.DataRow["UserName"].ToString(); } this.Controls.Add(attached); } } base.OnPreRender(e); }
/// <summary> /// Send Private Message /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { var replyTo = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("p").IsSet() ? this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("p").ToType <int>() : -1; // recipient was set in dropdown if (this.ToList.Visible) { this.To.Text = this.ToList.SelectedItem.Text; } if (this.To.Text.Length <= 0) { // recipient is required field YafContext.Current.AddLoadMessage(this.GetText("need_to"), MessageTypes.Warning); return; } // subject is required if (this.PmSubjectTextBox.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(this.GetText("need_subject"), MessageTypes.Warning); return; } // message is required if (this._editor.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(this.GetText("need_message"), MessageTypes.Warning); return; } if (this.ToList.SelectedItem != null && this.ToList.SelectedItem.Value == "0") { // administrator is sending PMs tp all users string body = this._editor.Text; var messageFlags = new MessageFlags { IsHtml = this._editor.UsesHTML, IsBBCode = this._editor.UsesBBCode }; // test user's PM count if (!this.VerifyMessageAllowed(1)) { return; } var receivingPMInfo = LegacyDb.user_pmcount(replyTo).Rows[0]; // test receiving user's PM count if (!YafContext.Current.IsAdmin || !(bool) Convert.ChangeType(UserMembershipHelper.GetUserRowForID(replyTo, true)["IsAdmin"], typeof(bool))) { if (receivingPMInfo["NumberTotal"].ToType <int>() + 1 <= receivingPMInfo["NumberAllowed"].ToType <int>()) { return; } // recipient has full PM box YafContext.Current.AddLoadMessage( this.GetTextFormatted("RECIPIENTS_PMBOX_FULL", this.To.Text), MessageTypes.Error); return; } LegacyDb.pmessage_save( YafContext.Current.PageUserID, 0, this.PmSubjectTextBox.Text, body, messageFlags.BitValue, replyTo); // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } else { // remove all abundant whitespaces and separators var rx = new Regex(@";(\s|;)*;"); this.To.Text = rx.Replace(this.To.Text, ";"); if (this.To.Text.StartsWith(";")) { this.To.Text = this.To.Text.Substring(1); } if (this.To.Text.EndsWith(";")) { this.To.Text = this.To.Text.Substring(0, this.To.Text.Length - 1); } rx = new Regex(@"\s*;\s*"); this.To.Text = rx.Replace(this.To.Text, ";"); // list of recipients var recipients = new List <string>(this.To.Text.Trim().Split(';')); if (recipients.Count > this.Get <YafBoardSettings>().PrivateMessageMaxRecipients && !YafContext.Current.IsAdmin && this.Get <YafBoardSettings>().PrivateMessageMaxRecipients != 0) { // to many recipients YafContext.Current.AddLoadMessage( this.GetTextFormatted( "TOO_MANY_RECIPIENTS", this.Get <YafBoardSettings>().PrivateMessageMaxRecipients), MessageTypes.Warning); return; } if (!this.VerifyMessageAllowed(recipients.Count)) { return; } // list of recipient's ids var recipientIds = new List <int>(); // get recipients' IDs foreach (string recipient in recipients) { int?userId = this.Get <IUserDisplayName>().GetId(recipient); if (!userId.HasValue) { YafContext.Current.AddLoadMessage( this.GetTextFormatted("NO_SUCH_USER", recipient), MessageTypes.Warning); return; } if (UserMembershipHelper.IsGuestUser(userId.Value)) { YafContext.Current.AddLoadMessage(this.GetText("NOT_GUEST"), MessageTypes.Error); return; } // get recipient's ID from the database if (!recipientIds.Contains(userId.Value)) { recipientIds.Add(userId.Value); } var receivingPMInfo = LegacyDb.user_pmcount(userId.Value).Rows[0]; // test receiving user's PM count if ((receivingPMInfo["NumberTotal"].ToType <int>() + 1 < receivingPMInfo["NumberAllowed"].ToType <int>()) || YafContext.Current.IsAdmin || (bool) Convert.ChangeType( UserMembershipHelper.GetUserRowForID(userId.Value, true)["IsAdmin"], typeof(bool))) { continue; } // recipient has full PM box YafContext.Current.AddLoadMessage( this.GetTextFormatted("RECIPIENTS_PMBOX_FULL", recipient), MessageTypes.Error); return; } // send PM to all recipients foreach (var userId in recipientIds) { string body = this._editor.Text; var messageFlags = new MessageFlags { IsHtml = this._editor.UsesHTML, IsBBCode = this._editor.UsesBBCode }; LegacyDb.pmessage_save( YafContext.Current.PageUserID, userId, this.PmSubjectTextBox.Text, body, messageFlags.BitValue, replyTo); // reset reciever's lazy data as he should be informed at once this.Get <IDataCache>().Remove(Constants.Cache.ActiveUserLazyData.FormatWith(userId)); if (this.Get <YafBoardSettings>().AllowPMEmailNotification) { this.Get <ISendNotification>() .ToPrivateMessageRecipient(userId, this.PmSubjectTextBox.Text.Trim()); } } // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } }
/// <summary> /// The render. /// </summary> /// <param name="output"> /// The output. /// </param> protected override void Render([NotNull] HtmlTextWriter output) { var displayName = this.ReplaceName.IsNotSet() ? this.Get <IUserDisplayName>().GetName(this.UserID) : this.ReplaceName; if (this.UserID == -1 || !displayName.IsSet()) { return; } // is this the guest user? If so, guest's don't have a profile. var isGuest = this.IsGuest ? this.IsGuest : UserMembershipHelper.IsGuestUser(this.UserID); output.BeginRender(); if (!isGuest) { output.WriteBeginTag("a"); output.WriteAttribute("href", YafBuildLink.GetLink(ForumPages.profile, "u={0}", this.UserID)); if (this.CanViewProfile && this.IsHoverCardEnabled) { if (this.CssClass.IsSet()) { this.CssClass += " userHoverCard"; } else { this.CssClass = "userHoverCard"; } output.WriteAttribute( "data-hovercard", "{0}resource.ashx?userinfo={1}&type=json&forumUrl={2}".FormatWith( YafForumInfo.ForumClientFileRoot, this.UserID, HttpUtility.UrlEncode(YafBuildLink.GetBasePath()))); } else { output.WriteAttribute("title", this.GetText("COMMON", "VIEW_USRPROFILE")); } if (this.Get <YafBoardSettings>().UseNoFollowLinks) { output.WriteAttribute("rel", "nofollow"); } if (this.BlankTarget) { output.WriteAttribute("target", "_blank"); } } else { output.WriteBeginTag("span"); } this.RenderMainTagAttributes(output); output.Write(HtmlTextWriter.TagRightChar); // Replace Name with Crawler Name if Set, otherwise use regular display name or Replace Name if set if (this.CrawlerName.IsSet()) { output.WriteEncodedText(this.CrawlerName); } else if (!this.CrawlerName.IsSet() && this.ReplaceName.IsSet() && isGuest) { output.WriteEncodedText(this.ReplaceName); } else { output.WriteEncodedText(displayName); } output.WriteEndTag(!isGuest ? "a" : "span"); if (this.PostfixText.IsSet()) { output.Write(this.PostfixText); } output.EndRender(); }
/// <summary> /// Handles click on save button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { var addedRoles = new List <string>(); var removedRoles = new List <string>(); // get user's name var userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID); var user = UserMembershipHelper.GetUser(userName); // go through all roles displayed on page for (var i = 0; i < this.UserGroups.Items.Count; i++) { // get current item var item = this.UserGroups.Items[i]; // get role ID from it var roleID = int.Parse(item.FindControlAs <Label>("GroupID").Text); // get role name var roleName = this.GetRepository <Group>().GetById(roleID).Name; // is user supposed to be in that role? var isChecked = item.FindControlAs <CheckBox>("GroupMember").Checked; // save user in role this.GetRepository <UserGroup>().Save(this.CurrentUserID, roleID, isChecked); // empty out access table(s) this.GetRepository <Active>().DeleteAll(); this.GetRepository <ActiveAccess>().DeleteAll(); // update roles if this user isn't the guest if (UserMembershipHelper.IsGuestUser(this.CurrentUserID)) { continue; } // add/remove user from roles in membership provider if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.AddUserToRole(userName, roleName); addedRoles.Add(roleName); } else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.RemoveUserFromRole(userName, roleName); removedRoles.Add(roleName); } // Clearing cache with old permissions data... this.Get <IDataCache>().Remove(string.Format(Constants.Cache.ActiveUserLazyData, this.CurrentUserID)); } if (this.SendEmail.Checked) { // send notification to user if (addedRoles.Any()) { this.Get <ISendNotification>().SendRoleAssignmentNotification(user, addedRoles); } if (removedRoles.Any()) { this.Get <ISendNotification>().SendRoleUnAssignmentNotification(user, removedRoles); } } // update forum moderators cache just in case something was changed... this.Get <IDataCache>().Remove(Constants.Cache.ForumModerators); // clear the cache for this user... this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID)); this.BindData(); }
/// <summary> /// Handles save button click event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { // recipient was set in dropdown if (this.ToList.Visible) { this.To.Text = this.ToList.SelectedItem.Text; } // Simon: Disable for admins DisablePMs = RoleMembershipHelper.IsUserInRole(this.To.Text, "Administrators"); if (DisablePMs) { return; } if (this.To.Text.Length <= 0) { // recipient is required field YafContext.Current.AddLoadMessage(GetText("need_to")); return; } // subject is required if (this.PmSubjectTextBox.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(GetText("need_subject")); return; } // message is required if (this._editor.Text.Trim().Length <= 0) { YafContext.Current.AddLoadMessage(GetText("need_message")); return; } if (this.ToList.SelectedItem != null && this.ToList.SelectedItem.Value == "0") { // administrator is sending PMs tp all users string body = this._editor.Text; var messageFlags = new MessageFlags(); messageFlags.IsHtml = this._editor.UsesHTML; messageFlags.IsBBCode = this._editor.UsesBBCode; DB.pmessage_save(YafContext.Current.PageUserID, 0, this.PmSubjectTextBox.Text, body, messageFlags.BitValue); // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } else { // remove all abundant whitespaces and separators this.To.Text.Trim(); var rx = new Regex(@";(\s|;)*;"); this.To.Text = rx.Replace(this.To.Text, ";"); if (this.To.Text.StartsWith(";")) { this.To.Text = this.To.Text.Substring(1); } if (this.To.Text.EndsWith(";")) { this.To.Text = this.To.Text.Substring(0, this.To.Text.Length - 1); } rx = new Regex(@"\s*;\s*"); this.To.Text = rx.Replace(this.To.Text, ";"); // list of recipients var recipients = new List <string>(this.To.Text.Trim().Split(';')); if (recipients.Count > YafContext.Current.BoardSettings.PrivateMessageMaxRecipients && !YafContext.Current.IsAdmin && YafContext.Current.BoardSettings.PrivateMessageMaxRecipients != 0) { // to many recipients YafContext.Current.AddLoadMessage(GetTextFormatted("TOO_MANY_RECIPIENTS", YafContext.Current.BoardSettings.PrivateMessageMaxRecipients)); return; } // test sending user's PM count // get user's name DataRow drPMInfo = DB.user_pmcount(YafContext.Current.PageUserID).Rows[0]; if ((Convert.ToInt32(drPMInfo["NumberTotal"]) > Convert.ToInt32(drPMInfo["NumberAllowed"]) + recipients.Count) && !YafContext.Current.IsAdmin) { // user has full PM box YafContext.Current.AddLoadMessage(GetTextFormatted("OWN_PMBOX_FULL", drPMInfo["NumberAllowed"])); return; } // list of recipient's ids var recipientIds = new List <int>(); // get recipients' IDs foreach (string recipient in recipients) { int?userId = PageContext.UserDisplayName.GetId(recipient); if (!userId.HasValue) { YafContext.Current.AddLoadMessage(GetTextFormatted("NO_SUCH_USER", recipient)); return; } else if (UserMembershipHelper.IsGuestUser(userId.Value)) { YafContext.Current.AddLoadMessage(GetText("NOT_GUEST")); return; } // get recipient's ID from the database if (!recipientIds.Contains(userId.Value)) { recipientIds.Add(userId.Value); } // test receiving user's PM count if ((DB.user_pmcount(userId.Value).Rows[0]["NumberTotal"].ToType <int>() >= DB.user_pmcount(userId.Value).Rows[0]["NumberAllowed"].ToType <int>()) && !YafContext.Current.IsAdmin && !(bool)Convert.ChangeType(UserMembershipHelper.GetUserRowForID(userId.Value, true)["IsAdmin"], typeof(bool))) { // recipient has full PM box YafContext.Current.AddLoadMessage(GetTextFormatted("RECIPIENTS_PMBOX_FULL", recipient)); return; } } // send PM to all recipients foreach (var userId in recipientIds) { string body = this._editor.Text; var messageFlags = new MessageFlags(); messageFlags.IsHtml = this._editor.UsesHTML; messageFlags.IsBBCode = this._editor.UsesBBCode; DB.pmessage_save(YafContext.Current.PageUserID, userId, this.PmSubjectTextBox.Text, body, messageFlags.BitValue); // reset reciever's lazy data as he should be informed at once PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(userId))); if (YafContext.Current.BoardSettings.AllowPMEmailNotification) { this.Get <YafSendNotification>().ToPrivateMessageRecipient(userId, this.PmSubjectTextBox.Text.Trim()); } } // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } }
/// <summary> /// The render. /// </summary> /// <param name="output"> /// The output. /// </param> protected override void Render([NotNull] HtmlTextWriter output) { var displayName = this.ReplaceName.IsNotSet() ? this.Get <IUserDisplayName>().GetName(this.UserID) : this.ReplaceName; if (this.UserID == -1 || !displayName.IsSet()) { return; } // is this the guest user? If so, guest's don't have a profile. var isGuest = this.IsGuest ? this.IsGuest : UserMembershipHelper.IsGuestUser(this.UserID); output.BeginRender(); if (!isGuest) { output.WriteBeginTag("a"); output.WriteAttribute("href", YafBuildLink.GetLink(ForumPages.profile, "u={0}&name={1}", this.UserID, displayName)); if (this.CanViewProfile && this.IsHoverCardEnabled) { if (this.CssClass.IsSet()) { this.CssClass += " btn-sm userHoverCard"; } else { this.CssClass = " btn-sm userHoverCard"; } output.WriteAttribute( "data-hovercard", "{0}resource.ashx?userinfo={1}&boardId={2}&type=json&forumUrl={3}".FormatWith( Config.IsDotNetNuke ? BaseUrlBuilder.GetBaseUrlFromVariables() + BaseUrlBuilder.AppPath : YafForumInfo.ForumClientFileRoot, this.UserID, YafContext.Current.PageBoardID, HttpUtility.UrlEncode(YafBuildLink.GetBasePath()))); } else { output.WriteAttribute("title", this.GetText("COMMON", "VIEW_USRPROFILE")); if (this.CssClass.IsSet()) { if (this.CssClass.Equals("dropdown-toggle")) { output.WriteAttribute("data-toggle", "dropdown"); output.WriteAttribute("aria-haspopup", "true"); output.WriteAttribute("aria-expanded", "false"); } this.CssClass += " btn-sm"; } else { this.CssClass = " btn-sm"; } } if (this.Get <YafBoardSettings>().UseNoFollowLinks) { output.WriteAttribute("rel", "nofollow"); } if (this.BlankTarget) { output.WriteAttribute("target", "_blank"); } } else { output.WriteBeginTag("span"); } this.RenderMainTagAttributes(output); output.Write(HtmlTextWriter.TagRightChar); // show online icon if (this.Get <YafBoardSettings>().ShowUserOnlineStatus) { var onlineStatusIcon = new OnlineStatusIcon { UserId = this.UserID }; onlineStatusIcon.RenderControl(output); output.Write(" "); } // Replace Name with Crawler Name if Set, otherwise use regular display name or Replace Name if set if (this.CrawlerName.IsSet()) { output.WriteEncodedText(this.CrawlerName); } else if (!this.CrawlerName.IsSet() && this.ReplaceName.IsSet() && isGuest) { output.WriteEncodedText(this.ReplaceName); } else { output.WriteEncodedText(displayName); } output.WriteEndTag(!isGuest ? "a" : "span"); if (this.PostfixText.IsSet()) { output.Write(this.PostfixText); } output.EndRender(); }