protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum)); PageLinks.AddLink("Administration", YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.admin_admin)); PageLinks.AddLink("Boards", ""); BindData(); if (BoardID != null) { CreateNewAdminHolder.Visible = false; using (DataTable dt = YAF.Classes.Data.DB.board_list(BoardID)) { DataRow row = dt.Rows [0]; Name.Text = ( string )row ["Name"]; AllowThreaded.Checked = SqlDataLayerConverter.VerifyBool(row ["AllowThreaded"]); BoardMembershipAppName.Text = row["MembershipAppName"].ToString(); } } else { UserName.Text = User.UserName; UserEmail.Text = User.Email; } } }
private void BindData() { ActiveList.DataSource = YAF.Classes.Data.DB.active_list(PageContext.PageBoardID, true); UserList.DataSource = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, null, false); DataBind(); // get stats for current board, selected board or all boards (see function) DataRow row = YAF.Classes.Data.DB.board_stats(GetSelectedBoardID()); NumPosts.Text = String.Format("{0:N0}", row ["NumPosts"]); NumTopics.Text = String.Format("{0:N0}", row ["NumTopics"]); NumUsers.Text = String.Format("{0:N0}", row ["NumUsers"]); TimeSpan span = DateTime.Now - ( DateTime )row ["BoardStart"]; double days = span.Days; BoardStart.Text = String.Format("{0:d} ({1:N0} days ago)", row ["BoardStart"], days); if (days < 1) { days = 1; } DayPosts.Text = String.Format("{0:N2}", SqlDataLayerConverter.VerifyInt32(row["NumPosts"]) / days); DayTopics.Text = String.Format("{0:N2}", SqlDataLayerConverter.VerifyInt32(row["NumTopics"]) / days); DayUsers.Text = String.Format("{0:N2}", SqlDataLayerConverter.VerifyInt32(row["NumUsers"]) / days); DBSize.Text = String.Format("{0} MB", DB.DBSize); }
private void InitPollUI(DataRow currentRow) { RemovePoll.CommandArgument = currentRow["PollID"].ToString(); if (currentRow["PollID"] != DBNull.Value) { DataTable choices = YAF.Classes.Data.DB.poll_stats(currentRow["PollID"]); Question.Text = choices.Rows[0]["Question"].ToString(); if (choices.Rows[0]["Closes"] != DBNull.Value) { TimeSpan closing = (DateTime)choices.Rows[0]["Closes"] - DateTime.Now; PollExpire.Text = (SqlDataLayerConverter.VerifyInt32((closing.TotalDays + 1)).ToString()); } else { PollExpire.Text = null; } for (int i = 0; i < choices.Rows.Count; i++) { HiddenField idField = (HiddenField)this.FindControl(String.Format("PollChoice{0}ID", i + 1)); TextBox choiceField = (TextBox)this.FindControl(String.Format("PollChoice{0}", i + 1)); idField.Value = choices.Rows[i]["ChoiceID"].ToString(); choiceField.Text = choices.Rows[i]["Choice"].ToString(); } ChangePollShowStatus(true); } }
private bool CanEditPostCheck(DataRow message) { bool postLocked = false; if (!PageContext.IsAdmin && PageContext.BoardSettings.LockPosts > 0) { DateTime edited = (DateTime)message["Edited"]; if (edited.AddDays(PageContext.BoardSettings.LockPosts) < DateTime.Now) { postLocked = true; } } DataRow forumInfo, topicInfo; // get topic and forum information topicInfo = DB.topic_info(PageContext.PageTopicID); using (DataTable dt = DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID)) forumInfo = dt.Rows[0]; // Ederon : 9/9/2007 - moderator can edit in locked topics return(((!postLocked && !General.BinaryAnd(forumInfo["Flags"], ForumFlags.Flags.IsLocked) && !General.BinaryAnd(topicInfo["Flags"], TopicFlags.Flags.IsLocked) && (SqlDataLayerConverter.VerifyInt32(message["UserID"]) == PageContext.PageUserID)) || PageContext.ForumModeratorAccess) && PageContext.ForumEditAccess); }
/// <summary> /// The init reply to topic. /// </summary> private void InitReplyToTopic() { DataRow topic = DB.topic_info(this.TopicID); var topicFlags = new TopicFlags(SqlDataLayerConverter.VerifyInt32(topic["Flags"])); // Ederon : 9/9/2007 - moderators can reply in locked topics if (topicFlags.IsLocked && !this.PageContext.ForumModeratorAccess) { this.Response.Redirect(this.Request.UrlReferrer.ToString()); } this.SubjectRow.Visible = false; this.Title.Text = this.GetText("reply"); // add topic link... this.PageLinks.AddLink( this.Server.HtmlDecode(topic["Topic"].ToString()), YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.TopicID)); // add "reply" text... this.PageLinks.AddLink(this.GetText("reply")); // show attach file option if its a reply... if (this.PageContext.ForumUploadAccess) { this.PostOptions1.Visible = true; this.PostOptions1.AttachOptionVisible = true; } // show the last posts AJAX frame... this.LastPosts1.Visible = true; this.LastPosts1.TopicID = this.TopicID.Value; }
private void BindData() { DataRow row; using (DataTable dt = YAF.Classes.Data.DB.board_list(PageContext.PageBoardID)) row = dt.Rows [0]; DataBind(); Name.Text = ( string )row ["Name"]; AllowThreaded.Checked = SqlDataLayerConverter.VerifyBool(row ["AllowThreaded"]); }
protected string GetImage(object o) { if (SqlDataLayerConverter.VerifyBool((( DataRowView )o) ["IsRead"])) { return(PageContext.Theme.GetItem("ICONS", "TOPIC")); } else { return(PageContext.Theme.GetItem("ICONS", "TOPIC_NEW")); } }
/// <summary> /// The user list_ item command. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> public void UserList_ItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": // we are going to edit user - redirect to edit page YafBuildLink.Redirect(ForumPages.admin_edituser, "u={0}", e.CommandArgument); break; case "delete": // we are deleting user if (this.PageContext.PageUserID == int.Parse(e.CommandArgument.ToString())) { // deleting yourself isn't an option this.PageContext.AddLoadMessage("You can't delete yourself."); return; } // get user(s) we are about to delete using (DataTable dt = DB.user_list(this.PageContext.PageBoardID, e.CommandArgument, DBNull.Value)) { // examine each if he's possible to delete foreach (DataRow row in dt.Rows) { if (SqlDataLayerConverter.VerifyInt32(row["IsGuest"]) > 0) { // we cannot detele guest this.PageContext.AddLoadMessage("You can't delete the Guest."); return; } if ((row["IsAdmin"] != DBNull.Value && SqlDataLayerConverter.VerifyInt32(row["IsAdmin"]) > 0) || (row["IsHostAdmin"] != DBNull.Value && Convert.ToInt32(row["IsHostAdmin"]) > 0)) { // admin are not deletable either this.PageContext.AddLoadMessage("You can't delete the Admin."); return; } } } // all is good, user can be deleted UserMembershipHelper.DeleteUser(Convert.ToInt32(e.CommandArgument)); // rebind data this.BindData(); // quit case break; } }
/// <summary> /// The bind data. /// </summary> private void BindData() { DataRow row; using (DataTable dt = DB.board_list(this.PageContext.PageBoardID)) { row = dt.Rows[0]; } this.DataBind(); this.Name.Text = row["Name"].ToString(); this.AllowThreaded.Checked = SqlDataLayerConverter.VerifyBool(row["AllowThreaded"]); }
protected string GetViewing(object o) { DataRow row = ( DataRow )o; int nViewing = SqlDataLayerConverter.VerifyInt32(row["Viewing"]); if (nViewing > 0) { return(" " + String.Format(PageContext.Localization.GetText("VIEWING"), nViewing)); } else { return(""); } }
/// <summary> /// The get viewing. /// </summary> /// <param name="o"> /// The o. /// </param> /// <returns> /// The get viewing. /// </returns> protected string GetViewing([NotNull] object o) { var row = (DataRow)o; int nViewing = SqlDataLayerConverter.VerifyInt32(row["Viewing"]); if (nViewing > 0) { return(" " + this.PageContext.Localization.GetTextFormatted("VIEWING", nViewing)); } else { return(string.Empty); } }
/// <summary> /// The setup user statistics. /// </summary> /// <param name="userData"> /// The user data. /// </param> private void SetupUserStatistics([NotNull] CombinedUserDataHelper userData) { double allPosts = 0.0; if (SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]) > 0) { allPosts = 100.0 * SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]); } this.Stats.InnerHtml = "{0:N0}<br />[{1} / {2}]".FormatWith( userData.DBRow["NumPosts"], this.GetTextFormatted("NUMALL", allPosts), this.GetTextFormatted( "NUMDAY", (double)SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumDays"]))); }
private void InitReplyToTopic() { DataRow topic = DB.topic_info(TopicID); TopicFlags topicFlags = new TopicFlags(SqlDataLayerConverter.VerifyInt32(topic["Flags"])); // Ederon : 9/9/2007 - moderators can reply in locked topics if (topicFlags.IsLocked && !PageContext.ForumModeratorAccess) { Response.Redirect(Request.UrlReferrer.ToString()); } SubjectRow.Visible = false; Title.Text = GetText("reply"); // add topic link... PageLinks.AddLink(Server.HtmlDecode(topic ["Topic"].ToString()), YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.posts, "t={0}", TopicID)); // add "reply" text... PageLinks.AddLink(GetText("reply")); // show attach file option if its a reply... if (PageContext.ForumUploadAccess) { NewTopicOptionsRow.Visible = true; TopicAttach.Visible = true; TopicAttachLabel.Visible = true; TopicWatch.Visible = false; TopicWatchLabel.Visible = false; TopicAttachBr.Visible = false; } if (YAF.Classes.Config.IsDotNetNuke || YAF.Classes.Config.IsRainbow || YAF.Classes.Config.IsPortal) { // can't use the last post iframe LastPosts.Visible = true; LastPosts.DataSource = DB.post_list_reverse10(TopicID); LastPosts.DataBind(); } else { LastPostsIFrame.Visible = true; LastPostsIFrame.Attributes.Add("src", string.Format("{0}framehelper.aspx?g=lastposts&t={1}", YafForumInfo.ForumRoot, TopicID)); } }
/// <summary> /// Handles click event of Update button. /// </summary> protected void Update_Click(object sender, System.EventArgs e) { // no user was specified if (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 (ToList.Visible) { UserName.Text = ToList.SelectedItem.Text; } // we need to verify user exists using (DataTable dt = YAF.Classes.Data.DB.user_find(PageContext.PageBoardID, false, UserName.Text, null)) { // there is no such user or reference is ambiugous if (dt.Rows.Count != 1) { PageContext.AddLoadMessage(GetText("NO_SUCH_USER")); return; } // we cannot use guest user here else if (SqlDataLayerConverter.VerifyInt32(dt.Rows[0]["IsGuest"]) > 0) { PageContext.AddLoadMessage(GetText("NOT_GUEST")); return; } // save permission YAF.Classes.Data.DB.userforum_save(dt.Rows[0]["UserID"], PageContext.PageForumID, AccessMaskID.SelectedValue); // redirect to forum moderation page YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.moderate, "f={0}", PageContext.PageForumID); // clear moderatorss cache YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink("Boards", string.Empty); this.Culture.DataSource = StaticDataHelper.Cultures(); this.Culture.DataValueField = "CultureTag"; this.Culture.DataTextField = "CultureNativeName"; BindData(); if (this.Culture.Items.Count > 0) { this.Culture.Items.FindByValue(this.PageContext.BoardSettings.Culture).Selected = true; } if (BoardID != null) { this.CreateNewAdminHolder.Visible = false; using (DataTable dt = DB.board_list(BoardID)) { DataRow row = dt.Rows[0]; this.Name.Text = (string)row["Name"]; this.AllowThreaded.Checked = SqlDataLayerConverter.VerifyBool(row["AllowThreaded"]); this.BoardMembershipAppName.Text = row["MembershipAppName"].ToString(); } } else { this.UserName.Text = User.UserName; this.UserEmail.Text = User.Email; } } }
public void UserList_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_edituser, "u={0}", e.CommandArgument); break; case "delete": if (PageContext.PageUserID == int.Parse(e.CommandArgument.ToString())) { PageContext.AddLoadMessage("You can't delete yourself."); return; } string userName = string.Empty; using (DataTable dt = YAF.Classes.Data.DB.user_list(PageContext.PageBoardID, e.CommandArgument, DBNull.Value)) { foreach (DataRow row in dt.Rows) { userName = ( string )row ["Name"]; if (SqlDataLayerConverter.VerifyInt32(row ["IsGuest"]) > 0) { PageContext.AddLoadMessage("You can't delete the Guest."); return; } if ((row["IsAdmin"] != DBNull.Value && SqlDataLayerConverter.VerifyInt32(row["IsAdmin"]) > 0) || (row["IsHostAdmin"] != DBNull.Value && Convert.ToInt32(row["IsHostAdmin"]) > 0)) { PageContext.AddLoadMessage("You can't delete the Admin."); return; } } } UserMembershipHelper.DeleteUser(Convert.ToInt32(e.CommandArgument)); BindData(); break; } }
/// <summary> /// The bind data. /// </summary> private void BindData() { DataTable activeList = DB.active_list( PageContext.PageBoardID, true, true, PageContext.BoardSettings.ActiveListTime, PageContext.BoardSettings.UseStyledNicks); // Set colorOnly parameter to false, as we get active users style from database if (PageContext.BoardSettings.UseStyledNicks) { new StyleTransform(PageContext.Theme).DecodeStyleByTable(ref activeList, false); } this.ActiveList.DataSource = activeList; this.UserList.DataSource = DB.user_list(PageContext.PageBoardID, null, false); DataBind(); // get stats for current board, selected board or all boards (see function) DataRow row = DB.board_stats(GetSelectedBoardID()); this.NumPosts.Text = "{0:N0}".FormatWith(row["NumPosts"]); this.NumTopics.Text = "{0:N0}".FormatWith(row["NumTopics"]); this.NumUsers.Text = "{0:N0}".FormatWith(row["NumUsers"]); TimeSpan span = DateTime.UtcNow - (DateTime)row["BoardStart"]; double days = span.Days; this.BoardStart.Text = "{0:d} ({1:N0} days ago)".FormatWith(row["BoardStart"], days); if (days < 1) { days = 1; } this.DayPosts.Text = "{0:N2}".FormatWith(SqlDataLayerConverter.VerifyInt32(row["NumPosts"]) / days); this.DayTopics.Text = "{0:N2}".FormatWith(SqlDataLayerConverter.VerifyInt32(row["NumTopics"]) / days); this.DayUsers.Text = "{0:N2}".FormatWith(SqlDataLayerConverter.VerifyInt32(row["NumUsers"]) / days); this.DBSize.Text = "{0} MB".FormatWith(DB.DBSize); }
/// <summary> /// The get image. /// </summary> /// <param name="o"> /// The o. /// </param> /// <returns> /// The get image. /// </returns> protected string GetImage(object o) { return(this.PageContext.Theme.GetItem( "ICONS", SqlDataLayerConverter.VerifyBool(((DataRowView)o)["IsRead"]) ? "TOPIC" : "TOPIC_NEW")); }
private bool CanHavePoll(DataRow message) { return((TopicID == null && QuotedTopicID == null && EditTopicID == null) || (message != null && (SqlDataLayerConverter.VerifyInt32(message["Position"])) == 0)); }
/// <summary> /// The can have poll. /// </summary> /// <param name="message"> /// The message. /// </param> /// <returns> /// The can have poll. /// </returns> private bool CanHavePoll(DataRow message) { return((this.TopicID == null && this.QuotedMessageID == null && this.EditMessageID == null) || (message != null && SqlDataLayerConverter.VerifyInt32(message["Position"]) == 0)); }
/// <summary> /// Handles save button click event. /// </summary> protected void Save_Click(object sender, EventArgs e) { // recipient was set in dropdown if (ToList.Visible) { To.Text = ToList.SelectedItem.Text; } if (To.Text.Length <= 0) { // recipient is required field PageContext.AddLoadMessage(GetText("need_to")); return; } // subject is required if (Subject.Text.Trim().Length <= 0) { PageContext.AddLoadMessage(GetText("need_subject")); return; } // message is required if (_editor.Text.Trim().Length <= 0) { PageContext.AddLoadMessage(GetText("need_message")); return; } if (ToList.SelectedItem != null && ToList.SelectedItem.Value == "0") { // administrator is sending PMs tp all users string body = _editor.Text; MessageFlags messageFlags = new MessageFlags(); messageFlags.IsHtml = _editor.UsesHTML; messageFlags.IsBBCode = _editor.UsesBBCode; DB.pmessage_save(PageContext.PageUserID, 0, Subject.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 To.Text.Trim(); Regex rx = new Regex(@";(\s|;)*;"); To.Text = rx.Replace(To.Text, ";"); if (To.Text.StartsWith(";")) { To.Text = To.Text.Substring(1); } if (To.Text.EndsWith(";")) { To.Text = To.Text.Substring(0, To.Text.Length - 1); } rx = new Regex(@"\s*;\s*"); To.Text = rx.Replace(To.Text, ";"); // list of recipients List <string> recipients = new List <string>(To.Text.Split(';')); // list of recipient's ids int [] recipientID = new int [recipients.Count]; if (recipients.Count > PageContext.BoardSettings.PrivateMessageMaxRecipients && !PageContext.IsAdmin) { // to many recipients PageContext.AddLoadMessage(String.Format(GetText("TOO_MANY_RECIPIENTS"), PageContext.BoardSettings.PrivateMessageMaxRecipients)); return; } // test sending user's PM count if (PageContext.BoardSettings.MaxPrivateMessagesPerUser != 0 && (DB.user_pmcount(PageContext.PageUserID) + recipients.Count) > PageContext.BoardSettings.MaxPrivateMessagesPerUser && !PageContext.IsAdmin) { // user has full PM box PageContext.AddLoadMessage(String.Format(GetText("OWN_PMBOX_FULL"), PageContext.BoardSettings.MaxPrivateMessagesPerUser)); return; } // get recipients' IDs for (int i = 0; i < recipients.Count; i++) { using (DataTable dt = DB.user_find(PageContext.PageBoardID, false, recipients [i], null)) { if (dt.Rows.Count != 1) { PageContext.AddLoadMessage(String.Format(GetText("NO_SUCH_USER"), recipients [i])); return; } else if (SqlDataLayerConverter.VerifyInt32(dt.Rows [0] ["IsGuest"]) > 0) { PageContext.AddLoadMessage(GetText("NOT_GUEST")); return; } // get recipient's ID from the database recipientID [i] = Convert.ToInt32(dt.Rows [0] ["UserID"]); // test receiving user's PM count if (PageContext.BoardSettings.MaxPrivateMessagesPerUser != 0 && DB.user_pmcount(recipientID [i]) >= PageContext.BoardSettings.MaxPrivateMessagesPerUser && !PageContext.IsAdmin) { // recipient has full PM box PageContext.AddLoadMessage(String.Format(GetText("RECIPIENTS_PMBOX_FULL"), recipients [i])); return; } } } // send PM to all recipients for (int i = 0; i < recipients.Count; i++) { string body = _editor.Text; MessageFlags messageFlags = new MessageFlags(); messageFlags.IsHtml = _editor.UsesHTML; messageFlags.IsBBCode = _editor.UsesBBCode; DB.pmessage_save(PageContext.PageUserID, recipientID [i], Subject.Text, body, messageFlags.BitValue); if (PageContext.BoardSettings.AllowPMEmailNotification) { SendPMNotification(recipientID [i], Subject.Text); } } // redirect to outbox (sent items), not control panel YafBuildLink.Redirect(ForumPages.cp_pm, "v={0}", "out"); } }
/// <summary> /// The init poll ui. /// </summary> /// <param name="pollID"> /// The poll ID. /// </param> private void InitPollUI(int?pollID) { // we should get the schema anyway this._choices = DB.poll_stats(pollID); this._choices.Columns.Add("ChoiceOrderID", typeof(int)); // First existing values alway 1! int existingRowsCount = 1; int allExistingRowsCount = this._choices.Rows.Count; // we edit existing poll if (this._choices.Rows.Count > 0) { if ((Convert.ToInt32(this._choices.Rows[0]["UserID"]) != this.PageContext.PageUserID) && (!this.PageContext.IsAdmin) && (!this.PageContext.IsForumModerator)) { YafBuildLink.RedirectInfoPage(InfoMessage.Invalid); } this.IsBoundCheckBox.Checked = this._choices.Rows[0]["IsBound"].ToType <bool>(); this.IsClosedBoundCheckBox.Checked = this._choices.Rows[0]["IsClosedBound"].ToType <bool>(); this.AllowMultipleChoicesCheckBox.Checked = this._choices.Rows[0]["AllowMultipleChoices"].ToType <bool>(); this.Question.Text = this._choices.Rows[0]["Question"].ToString(); this.QuestionObjectPath.Text = this._choices.Rows[0]["QuestionObjectPath"].ToString(); if (this._choices.Rows[0]["Closes"] != DBNull.Value) { TimeSpan closing = (DateTime)this._choices.Rows[0]["Closes"] - DateTime.UtcNow; this.PollExpire.Text = SqlDataLayerConverter.VerifyInt32(closing.TotalDays + 1).ToString(); } else { this.PollExpire.Text = null; } foreach (DataRow choiceRow in this._choices.Rows) { choiceRow["ChoiceOrderID"] = existingRowsCount; existingRowsCount++; } } else { // A new topic is created // below check currently if works for topics only, but will do as some things are not enabled if (!CanCreatePoll()) { YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied); } // Get isBound value using page variables. They are initialized here. int pgidt = 0; // If a topic poll is edited or new topic created if (this._topicId > 0 && this._topicInfo != null) { // topicid should not be null here if (!this._topicInfo["PollID"].IsNullOrEmptyDBField()) { pgidt = (int)this._topicInfo["PollID"]; DataTable pollGroupData = DB.pollgroup_stats(pgidt); this.IsBoundCheckBox.Checked = Convert.ToBoolean(pollGroupData.Rows[0]["IsBound"]); // this.IsClosedBoundCheckBox.Checked = Convert.ToBoolean(DB.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"]); } } else if (this._forumId > 0 && (!(this._topicId > 0) || (!(this._editTopicId > 0)))) { // forumid should not be null here pgidt = (int)DB.forum_list(this.PageContext.PageBoardID, this._forumId).Rows[0]["PollGroupID"]; } else if (this._categoryId > 0) { // categoryid should not be null here pgidt = (int) DB.category_listread(this.PageContext.PageBoardID, this.PageContext.PageUserID, this._categoryId).Rows[0][ "PollGroupID"]; } if (pgidt > 0) { if (Convert.ToInt32(DB.pollgroup_stats(pgidt).Rows[0]["IsBound"]) == 2) { this.IsBoundCheckBox.Checked = true; } if (Convert.ToInt32(DB.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"]) == 4) { this.IsClosedBoundCheckBox.Checked = true; } } // clear the fields... this.PollExpire.Text = string.Empty; this.Question.Text = string.Empty; } // we add dummy rows to data table to fill in repeater empty fields int dummyRowsCount = this.PageContext.BoardSettings.AllowedPollChoiceNumber - allExistingRowsCount - 1; for (int i = 0; i <= dummyRowsCount; i++) { DataRow drow = this._choices.NewRow(); drow["ChoiceOrderID"] = existingRowsCount + i; this._choices.Rows.Add(drow); } // Bind choices repeater this.ChoiceRepeater.DataSource = this._choices; this.ChoiceRepeater.DataBind(); this.ChoiceRepeater.Visible = true; // Show controls this.SavePoll.Visible = true; this.Cancel.Visible = true; this.PollRow1.Visible = true; this.PollRowExpire.Visible = true; this.IsClosedBound.Visible = this.IsBound.Visible = PageContext.BoardSettings.AllowUsersHidePollResults || PageContext.IsAdmin || PageContext.IsForumModerator; this.tr_AllowMultipleChoices.Visible = PageContext.BoardSettings.AllowMultipleChoices || PageContext.IsAdmin || PageContext.IsForumModerator; }
private void BindData() { int userID = ( int )Security.StringToLongOrRedirect(Request.QueryString ["u"]); MembershipUser user = UserMembershipHelper.GetMembershipUser(userID); if (user == null) { YafBuildLink.AccessDenied(/*No such user exists*/); } YafCombinedUserData userData = new YafCombinedUserData(user, userID); // populate user information controls... UserName.Text = HtmlEncode(userData.Membership.UserName); Name.Text = HtmlEncode(userData.Membership.UserName); Joined.Text = String.Format("{0}", YafDateTime.FormatDateLong(Convert.ToDateTime(userData.Joined))); LastVisit.Text = YafDateTime.FormatDateTime(userData.LastVisit); Rank.Text = userData.RankName; Location.Text = HtmlEncode(General.BadWordReplace(userData.Profile.Location)); RealName.InnerHtml = HtmlEncode(General.BadWordReplace(userData.Profile.RealName)); Interests.InnerHtml = HtmlEncode(General.BadWordReplace(userData.Profile.Interests)); Occupation.InnerHtml = HtmlEncode(General.BadWordReplace(userData.Profile.Occupation)); Gender.InnerText = GetText("GENDER" + userData.Profile.Gender); PageLinks.Clear(); PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum)); PageLinks.AddLink(GetText("MEMBERS"), YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.members)); PageLinks.AddLink(userData.Membership.UserName, ""); double dAllPosts = 0.0; if (SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]) > 0) { dAllPosts = 100.0 * SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPostsForum"]); } Stats.InnerHtml = String.Format("{0:N0}<br/>[{1} / {2}]", userData.DBRow ["NumPosts"], String.Format(GetText("NUMALL"), dAllPosts), String.Format(GetText("NUMDAY"), (double)SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumPosts"]) / SqlDataLayerConverter.VerifyInt32(userData.DBRow["NumDays"])) ); // private messages ///CHANGED THIS ON 12/1/2010 //PM.Visible = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowPrivateMessages; PM.Visible = false; PM.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.pmessage, "u={0}", userData.UserID); // email link Email.Visible = !userData.IsGuest && User != null && PageContext.BoardSettings.AllowEmailSending; Email.NavigateUrl = YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID); if (PageContext.IsAdmin) { Email.TitleNonLocalized = userData.Membership.Email; } // homepage link Home.Visible = !String.IsNullOrEmpty(userData.Profile.Homepage); SetupThemeButtonWithLink(Home, userData.Profile.Homepage); // blog link Blog.Visible = !String.IsNullOrEmpty(userData.Profile.Blog); SetupThemeButtonWithLink(Blog, userData.Profile.Blog); MSN.Visible = (User != null && !String.IsNullOrEmpty(userData.Profile.MSN)); MSN.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_email, "u={0}", userData.UserID); YIM.Visible = (User != null && !String.IsNullOrEmpty(userData.Profile.YIM)); YIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_yim, "u={0}", userData.UserID); AIM.Visible = (User != null && !String.IsNullOrEmpty(userData.Profile.AIM)); AIM.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_aim, "u={0}", userData.UserID); ICQ.Visible = (User != null && !String.IsNullOrEmpty(userData.Profile.ICQ)); ICQ.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_icq, "u={0}", userData.UserID); Skype.Visible = (User != null && !String.IsNullOrEmpty(userData.Profile.Skype)); Skype.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.im_skype, "u={0}", userData.UserID); // localize tab titles... AboutTab.HeaderText = GetText("ABOUT"); StatisticsTab.HeaderText = GetText("STATISTICS"); AvatarTab.HeaderText = GetText("AVATAR"); Last10PostsTab.HeaderText = GetText("LAST10"); if (PageContext.BoardSettings.AvatarUpload && userData.HasAvatarImage) { Avatar.ImageUrl = YafForumInfo.ForumRoot + "resource.ashx?u=" + (userID); } else if (!String.IsNullOrEmpty(userData.Avatar)) // Took out PageContext.BoardSettings.AvatarRemote { Avatar.ImageUrl = String.Format("{3}resource.ashx?url={0}&width={1}&height={2}", Server.UrlEncode(userData.Avatar), PageContext.BoardSettings.AvatarWidth, PageContext.BoardSettings.AvatarHeight, YafForumInfo.ForumRoot); } else { Avatar.Visible = false; AvatarTab.Visible = false; } Groups.DataSource = Roles.GetRolesForUser(UserMembershipHelper.GetUserNameFromID(userID)); //EmailRow.Visible = PageContext.IsAdmin; ModerateTab.Visible = PageContext.IsAdmin || PageContext.IsForumModerator; AdminUserButton.Visible = PageContext.IsAdmin; if (LastPosts.Visible) { LastPosts.DataSource = YAF.Classes.Data.DB.post_last10user(PageContext.PageBoardID, Request.QueryString ["u"], PageContext.PageUserID); SearchUser.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.search, "postedby={0}", userData.Membership.UserName); } DataBind(); }