/// <summary> /// Saves the user Block Options /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void SaveUser_OnClick(object sender, EventArgs e) { var blockFlags = new UserBlockFlags { BlockEmails = this.BlockEmails.Checked, BlockFriendRequests = this.BlockFriendRequests.Checked, BlockPMs = this.BlockPMs.Checked }; this.GetRepository <User>().UpdateBlockFlags(this.PageContext.PageUserID, blockFlags.BitValue); this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.PageContext.PageUserID)); }
/// <summary> /// The admins list_ on item data bound. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void AdminsList_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var adminAvatar = e.Item.FindControlAs <Image>("AdminAvatar"); var itemDataItem = (DataRowView)e.Item.DataItem; var userid = itemDataItem["UserID"].ToType <int>(); var displayName = this.Get <BoardSettings>().EnableDisplayName ? itemDataItem.Row["DisplayName"].ToString() : itemDataItem.Row["Name"].ToString(); adminAvatar.ImageUrl = this.GetAvatarUrlFileName( itemDataItem.Row["UserID"].ToType <int>(), itemDataItem.Row["Avatar"].ToString(), itemDataItem.Row["AvatarImage"].ToString().IsSet(), itemDataItem.Row["Email"].ToString()); adminAvatar.AlternateText = displayName; adminAvatar.ToolTip = displayName; // User Buttons var adminUserButton = e.Item.FindControlAs <ThemeButton>("AdminUserButton"); var pm = e.Item.FindControlAs <ThemeButton>("PM"); var email = e.Item.FindControlAs <ThemeButton>("Email"); adminUserButton.Visible = this.PageContext.IsAdmin; if (userid == this.PageContext.PageUserID) { return; } var blockFlags = new UserBlockFlags(itemDataItem.Row["BlockFlags"].ToType <int>()); var isFriend = this.GetRepository <Buddy>().CheckIsFriend(this.PageContext.PageUserID, userid); pm.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowPrivateMessages; if (pm.Visible) { if (blockFlags.BlockPMs) { pm.Visible = false; } if (this.PageContext.IsAdmin || isFriend) { pm.Visible = true; } } pm.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.PostPrivateMessage, "u={0}", userid); pm.ParamTitle0 = displayName; // email link email.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowEmailSending; if (email.Visible) { if (blockFlags.BlockEmails) { email.Visible = false; } if (this.PageContext.IsAdmin && isFriend) { email.Visible = true; } email.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.Email, "u={0}", userid); email.ParamTitle0 = displayName; } }
/// <summary> /// Setup the popup menu. /// </summary> private void SetupPopupMenu() { this.UserDropHolder.Controls.Add( new ThemeButton { Type = ButtonStyle.None, Icon = "th-list", TextLocalizedPage = "PAGE", TextLocalizedTag = "SEARCHUSER", CssClass = "dropdown-item", NavigateUrl = BuildLink.GetLink( ForumPages.Search, "postedby={0}", this.DataRow[this.Get <BoardSettings>().EnableDisplayName ? "DisplayName" : "UserName"]) }); this.UserDropHolder2.Controls.Add( new ThemeButton { Type = ButtonStyle.None, Icon = "th-list", TextLocalizedPage = "PAGE", TextLocalizedTag = "SEARCHUSER", CssClass = "dropdown-item", NavigateUrl = BuildLink.GetLink( ForumPages.Search, "postedby={0}", this.DataRow[this.Get <BoardSettings>().EnableDisplayName ? "DisplayName" : "UserName"]) }); if (this.PageContext.IsAdmin) { this.UserDropHolder.Controls.Add( new ThemeButton { Type = ButtonStyle.None, Icon = "cogs", TextLocalizedPage = "POSTS", TextLocalizedTag = "EDITUSER", CssClass = "dropdown-item", NavigateUrl = BuildLink.GetLink(ForumPages.Admin_EditUser, "u={0}", this.PostData.UserId) }); this.UserDropHolder2.Controls.Add( new ThemeButton { Type = ButtonStyle.None, Icon = "cogs", TextLocalizedPage = "POSTS", TextLocalizedTag = "EDITUSER", CssClass = "dropdown-item", NavigateUrl = BuildLink.GetLink(ForumPages.Admin_EditUser, "u={0}", this.PostData.UserId) }); } if (this.PageContext.PageUserID != this.PostData.UserId) { if (this.Get <IUserIgnored>().IsIgnored(this.PostData.UserId)) { var showButton = new ThemeButton { Type = ButtonStyle.None, Icon = "eye", TextLocalizedPage = "POSTS", TextLocalizedTag = "TOGGLEUSERPOSTS_SHOW", CssClass = "dropdown-item" }; showButton.Click += (sender, args) => { this.Get <IUserIgnored>().RemoveIgnored(this.PostData.UserId); this.Get <HttpResponseBase>().Redirect(this.Get <HttpRequestBase>().RawUrl); }; this.UserDropHolder.Controls.Add(showButton); } else { var hideButton = new ThemeButton { Type = ButtonStyle.None, Icon = "eye-slash", TextLocalizedPage = "POSTS", TextLocalizedTag = "TOGGLEUSERPOSTS_HIDE", CssClass = "dropdown-item" }; hideButton.Click += (sender, args) => { this.Get <IUserIgnored>().AddIgnored(this.PostData.UserId); this.Get <HttpResponseBase>().Redirect(this.Get <HttpRequestBase>().RawUrl); }; this.UserDropHolder.Controls.Add(hideButton); } } if (this.Get <BoardSettings>().EnableBuddyList&& this.PageContext.PageUserID != this.PostData.UserId) { var userBlockFlags = new UserBlockFlags(this.DataRow.Field <int>("BlockFlags")); // Should we add the "Add Buddy" item? if (!this.Get <IFriends>().IsBuddy(this.PostData.UserId, false) && !this.PageContext.IsGuest && !userBlockFlags .BlockFriendRequests) { var addFriendButton = new ThemeButton { Type = ButtonStyle.None, Icon = "user-plus", TextLocalizedPage = "BUDDY", TextLocalizedTag = "ADDBUDDY", CssClass = "dropdown-item" }; addFriendButton.Click += (sender, args) => { var strBuddyRequest = this.Get <IFriends>().AddRequest(this.PostData.UserId); if (Convert.ToBoolean(strBuddyRequest[1].ToType <int>())) { this.PageContext.AddLoadMessage( this.GetTextFormatted("NOTIFICATION_BUDDYAPPROVED_MUTUAL", strBuddyRequest[0]), MessageTypes.success); this.Get <HttpResponseBase>().Redirect(this.Get <HttpRequestBase>().RawUrl); } else { this.PageContext.AddLoadMessage( this.GetText("NOTIFICATION_BUDDYREQUEST"), MessageTypes.success); } }; this.UserDropHolder.Controls.Add(addFriendButton); } else if (this.Get <IFriends>().IsBuddy(this.PostData.UserId, true) && !this.PageContext.IsGuest) { // Are the users approved buddies? Add the "Remove buddy" item. var removeFriendButton = new ThemeButton { Type = ButtonStyle.None, Icon = "user-times", TextLocalizedPage = "BUDDY", TextLocalizedTag = "REMOVEBUDDY", CssClass = "dropdown-item", ReturnConfirmText = this.GetText( "FRIENDS", "NOTIFICATION_REMOVE") }; removeFriendButton.Click += (sender, args) => { this.Get <IFriends>().Remove(this.PostData.UserId); this.Get <HttpResponseBase>().Redirect(this.Get <HttpRequestBase>().RawUrl); this.PageContext.AddLoadMessage( this.GetTextFormatted( "REMOVEBUDDY_NOTIFICATION", this.Get <IFriends>().Remove(this.PostData.UserId)), MessageTypes.success); }; this.UserDropHolder.Controls.Add(removeFriendButton); } } this.UserDropHolder.Controls.Add(new Panel { CssClass = "dropdown-divider" }); this.UserDropHolder2.Controls.Add(new Panel { CssClass = "dropdown-divider" }); }