/// <summary> /// The setup buddy list. /// </summary> /// <param name="userID"> /// The user id. /// </param> /// <param name="userData"> /// The user data. /// </param> private void SetupBuddyList(int userID, [NotNull] CombinedUserDataHelper userData) { if (userID == this.PageContext.PageUserID) { this.lnkBuddy.Visible = false; } else if (YafBuddies.IsBuddy((int)userData.DBRow["userID"], true) && !this.PageContext.IsGuest) { this.lnkBuddy.Visible = true; this.lnkBuddy.Text = "({0})".FormatWith(this.PageContext.Localization.GetText("BUDDY", "REMOVEBUDDY")); this.lnkBuddy.CommandArgument = "removebuddy"; this.lnkBuddy.Attributes["onclick"] = String.Format( "return confirm('{0}')", this.PageContext.Localization.GetText("CP_EDITBUDDIES", "NOTIFICATION_REMOVE")); } else if (YafBuddies.IsBuddy((int)userData.DBRow["userID"], false)) { this.lnkBuddy.Visible = false; this.ltrApproval.Visible = true; } else { if (!this.PageContext.IsGuest) { this.lnkBuddy.Visible = true; this.lnkBuddy.Text = "({0})".FormatWith(this.PageContext.Localization.GetText("BUDDY", "ADDBUDDY")); this.lnkBuddy.CommandArgument = "addbuddy"; this.lnkBuddy.Attributes["onclick"] = string.Empty; } } this.BuddyList.CurrentUserID = userID; this.BuddyList.Mode = 1; }
/// <summary> /// The lnk_ add buddy. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void lnk_AddBuddy([NotNull] object sender, [NotNull] CommandEventArgs e) { if (e.CommandArgument.ToString() == "addbuddy") { string[] strBuddyRequest = YafBuddies.AddBuddyRequest(this.UserId); var linkButton = (LinkButton)this.AboutTab.FindControl("lnkBuddy"); linkButton.Visible = false; if (Convert.ToBoolean(strBuddyRequest[1])) { this.PageContext.AddLoadMessage( this.PageContext.Localization.GetText("NOTIFICATION_BUDDYAPPROVED_MUTUAL").FormatWith(strBuddyRequest[0])); } else { var literal = (Literal)this.AboutTab.FindControl("ltrApproval"); literal.Visible = true; this.PageContext.AddLoadMessage(this.PageContext.Localization.GetText("NOTIFICATION_BUDDYREQUEST")); } } else { this.PageContext.AddLoadMessage( this.PageContext.Localization.GetText("REMOVEBUDDY_NOTIFICATION").FormatWith( YafBuddies.RemoveBuddy(this.UserId))); } this.BindData(); }
/// <summary> /// The bind data. /// </summary> private void BindData() { this.Pager.PageSize = 20; // set the Datatable DataTable buddyListDataTable = YafBuddies.GetBuddiesForUser(CurrentUserID); if ((buddyListDataTable != null) && (buddyListDataTable.Rows.Count > 0)) { // get the view from the datatable DataView buddyListDataView = buddyListDataTable.DefaultView; // In what mode should this control work? // Refer to "rptBuddy_ItemCreate" event for more info. switch (Mode) { case 1: case 2: buddyListDataView.RowFilter = "Approved = 1".FormatWith(this.CurrentUserID); break; case 3: buddyListDataView.RowFilter = "Approved = 0 AND FromUserID <> {0}".FormatWith(this.CurrentUserID); break; case 4: buddyListDataView.RowFilter = "Approved = 0 AND FromUserID = {0}".FormatWith(this.CurrentUserID); break; } this.Pager.Count = buddyListDataView.Count; // create paged data source for the buddylist buddyListDataView.Sort = "{0} {1}".FormatWith(this.ViewState["SortField"], (bool)this.ViewState["SortAscending"] ? "asc" : "desc"); var pds = new PagedDataSource(); pds.DataSource = buddyListDataView; pds.AllowPaging = true; pds.CurrentPageIndex = this.Pager.CurrentPageIndex; pds.PageSize = this.Pager.PageSize; this.rptBuddy.DataSource = pds; } DataBind(); // handle the sort fields at the top // TODO: make these "sorts" into controls ForumPage fp = new ForumPage(); this.SortUserName.Visible = (string)ViewState["SortField"] == "Name"; this.SortUserName.Src = fp.GetThemeContents("SORT", (bool)ViewState["SortAscending"] ? "ASCENDING" : "DESCENDING"); this.SortRank.Visible = (string)ViewState["SortField"] == "RankName"; this.SortRank.Src = this.SortUserName.Src; this.SortJoined.Visible = (string)ViewState["SortField"] == "Joined"; this.SortJoined.Src = this.SortUserName.Src; this.SortPosts.Visible = (string)ViewState["SortField"] == "NumPosts"; this.SortPosts.Src = this.SortUserName.Src; }
/// <summary> /// The ItemCommand method for the link buttons in the last column. /// </summary> /// <param name="sender"> /// the sender. /// </param> /// <param name="e"> /// the e. /// </param> protected void rptBuddy_ItemCommand(object sender, CommandEventArgs e) { switch (e.CommandName) { case "remove": PageContext.AddLoadMessage(this.PageContext.Localization.GetText("REMOVEBUDDY_NOTIFICATION").FormatWith(YafBuddies.RemoveBuddy(Convert.ToInt32(e.CommandArgument)))); CurrentUserID = PageContext.PageUserID; break; case "approve": PageContext.AddLoadMessage(this.PageContext.Localization.GetText("NOTIFICATION_BUDDYAPPROVED").FormatWith(YafBuddies.ApproveBuddyRequest(Convert.ToInt32(e.CommandArgument), false))); break; case "approveadd": PageContext.AddLoadMessage(this.PageContext.Localization.GetText("NOTIFICATION_BUDDYAPPROVED_MUTUAL").FormatWith(YafBuddies.ApproveBuddyRequest(Convert.ToInt32(e.CommandArgument), true))); break; case "approveall": YafBuddies.ApproveAllBuddyRequests(false); PageContext.AddLoadMessage(PageContext.Localization.GetText("NOTIFICATION_ALL_APPROVED")); break; case "approveaddall": YafBuddies.ApproveAllBuddyRequests(true); PageContext.AddLoadMessage(PageContext.Localization.GetText("NOTIFICATION_ALL_APPROVED_ADDED")); break; case "deny": YafBuddies.DenyBuddyRequest(Convert.ToInt32(e.CommandArgument)); PageContext.AddLoadMessage(PageContext.Localization.GetText("NOTIFICATION_BUDDYDENIED")); break; case "denyall": YafBuddies.DenyAllBuddyRequests(); PageContext.AddLoadMessage(PageContext.Localization.GetText("NOTIFICATION_ALL_DENIED")); break; } // Update all buddy list controls in cp_editbuddies.ascx page. UpdateBuddyList(ControlHelper.FindControlRecursiveAs <BuddyList>(Container, "BuddyList1"), 2); UpdateBuddyList(ControlHelper.FindControlRecursiveAs <BuddyList>(Container, "PendingBuddyList"), 3); UpdateBuddyList(ControlHelper.FindControlRecursiveAs <BuddyList>(Container, "BuddyRequested"), 4); }
/// <summary> /// The pop menu 1_ item click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void PopMenu1_ItemClick([NotNull] object sender, [NotNull] PopEventArgs e) { switch (e.Item) { case "userprofile": YafBuildLink.Redirect(ForumPages.profile, "u={0}", this.PostData.UserId); break; case "lastposts": YafBuildLink.Redirect(ForumPages.search, "postedby={0}", this.PostData.UserProfile.UserName); break; case "addbuddy": var strBuddyRequest = new string[2]; this.PopMenu1.RemovePostBackItem("addbuddy"); strBuddyRequest = YafBuddies.AddBuddyRequest(this.PostData.UserId); if (Convert.ToBoolean(strBuddyRequest[1])) { this.PageContext.AddLoadMessage( this.PageContext.Localization.GetText("NOTIFICATION_BUDDYAPPROVED_MUTUAL").FormatWith(strBuddyRequest[0])); this.PopMenu1.AddClientScriptItemWithPostback( this.PageContext.Localization.GetText("BUDDY", "REMOVEBUDDY"), "removebuddy", "if (confirm('{0}')) {1}".FormatWith(this.PageContext.Localization.GetText("CP_EDITBUDDIES", "NOTIFICATION_REMOVE"), "{postbackcode}")); } else { this.PageContext.AddLoadMessage(this.PageContext.Localization.GetText("NOTIFICATION_BUDDYREQUEST")); } break; case "removebuddy": { this.PopMenu1.RemovePostBackItem("removebuddy"); this.PopMenu1.AddPostBackItem("addbuddy", this.PageContext.Localization.GetText("BUDDY", "ADDBUDDY")); this.PageContext.AddLoadMessage( this.PageContext.Localization.GetText("REMOVEBUDDY_NOTIFICATION").FormatWith( YafBuddies.RemoveBuddy(this.PostData.UserId))); break; } case "edituser": YafBuildLink.Redirect(ForumPages.admin_edituser, "u={0}", this.PostData.UserId); break; case "toggleuserposts_show": this.Get <YafUserIgnored>().RemoveIgnored(this.PostData.UserId); this.Response.Redirect(this.Request.RawUrl); break; case "toggleuserposts_hide": this.Get <YafUserIgnored>().AddIgnored(this.PostData.UserId); this.Response.Redirect(this.Request.RawUrl); break; case "viewthanks": YafBuildLink.Redirect(ForumPages.viewthanks, "u={0}", this.PostData.UserId); break; } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.PageContext.BoardSettings.EnableThanksMod) { Utility.RegisterTypeForAjax(typeof(ThankYou)); string addThankBoxHTML = "'<a class=\"yaflittlebutton\" href=\"javascript:addThanks(' + res.value.MessageID + ');\" onclick=\"this.blur();\" title=' + res.value.Title + '><span>' + res.value.Text + '</span></a>'"; string removeThankBoxHTML = "'<a class=\"yaflittlebutton\" href=\"javascript:removeThanks(' + res.value.MessageID + ');\" onclick=\"this.blur();\" title=' + res.value.Title + '><span>' + res.value.Text + '</span></a>'"; YafContext.Current.PageElements.RegisterJsBlockStartup( "addThanksJs", JavaScriptBlocks.addThanksJs(removeThankBoxHTML)); YafContext.Current.PageElements.RegisterJsBlockStartup( "removeThanksJs", JavaScriptBlocks.removeThanksJs(addThankBoxHTML)); YafContext.Current.PageElements.RegisterJsBlockStartup( "asynchCallFailedJs", JavaScriptBlocks.asynchCallFailedJs); } // Irkoo Service Enabled? if (YafContext.Current.BoardSettings.EnableIrkoo) { YafContext.Current.PageElements.RegisterJsBlockStartup("IrkooMethods", YafIrkoo.IrkJsCode()); } this.PopMenu1.Visible = !this.IsGuest; if (this.PopMenu1.Visible) { this.PopMenu1.ItemClick += this.PopMenu1_ItemClick; this.PopMenu1.AddPostBackItem("userprofile", this.PageContext.Localization.GetText("POSTS", "USERPROFILE")); this.PopMenu1.AddPostBackItem("lastposts", this.PageContext.Localization.GetText("PROFILE", "SEARCHUSER")); if (YafContext.Current.BoardSettings.EnableThanksMod) { this.PopMenu1.AddPostBackItem("viewthanks", this.PageContext.Localization.GetText("VIEWTHANKS", "TITLE")); } if (this.PageContext.IsAdmin) { this.PopMenu1.AddPostBackItem("edituser", "Edit User (Admin)"); } if (!this.PageContext.IsGuest) { if (this.Get <YafUserIgnored>().IsIgnored(this.PostData.UserId)) { this.PopMenu1.AddPostBackItem( "toggleuserposts_show", this.PageContext.Localization.GetText("POSTS", "TOGGLEUSERPOSTS_SHOW")); } else { this.PopMenu1.AddPostBackItem( "toggleuserposts_hide", this.PageContext.Localization.GetText("POSTS", "TOGGLEUSERPOSTS_HIDE")); } } if (YafContext.Current.BoardSettings.EnableBuddyList && this.PageContext.PageUserID != (int)this.DataRow["UserID"]) { // Should we add the "Add Buddy" item? if (!YafBuddies.IsBuddy((int)this.DataRow["UserID"], false) && !this.PageContext.IsGuest) { this.PopMenu1.AddPostBackItem("addbuddy", this.PageContext.Localization.GetText("BUDDY", "ADDBUDDY")); } else if (YafBuddies.IsBuddy((int)this.DataRow["UserID"], true) && !this.PageContext.IsGuest) { // Are the users approved buddies? Add the "Remove buddy" item. this.PopMenu1.AddClientScriptItemWithPostback( this.PageContext.Localization.GetText("BUDDY", "REMOVEBUDDY"), "removebuddy", "if (confirm('{0}')) {1}".FormatWith(this.PageContext.Localization.GetText("CP_EDITBUDDIES", "NOTIFICATION_REMOVE"), "{postbackcode}")); } } this.PopMenu1.Attach(this.UserProfileLink); } // setup jQuery, LightBox and YAF JS... YafContext.Current.PageElements.RegisterJQuery(); YafContext.Current.PageElements.RegisterJsResourceInclude("yafjs", "js/yaf.js"); YafContext.Current.PageElements.RegisterJsBlock("toggleMessageJs", JavaScriptBlocks.ToggleMessageJs); // lightbox only need if the browser is not IE6... if (!UserAgentHelper.IsBrowserIE6()) { YafContext.Current.PageElements.RegisterJsResourceInclude("lightboxjs", "js/jquery.lightbox.min.js"); YafContext.Current.PageElements.RegisterCssIncludeResource("css/jquery.lightbox.css"); YafContext.Current.PageElements.RegisterJsBlock("lightboxloadjs", JavaScriptBlocks.LightBoxLoadJs); } this.NameCell.ColSpan = int.Parse(this.GetIndentSpan()); }