Exemple #1
0
 /// <summary>
 /// Determines whether [is user host admin]
 /// </summary>
 /// <param name="userRow">The user row.</param>
 /// <returns>
 /// The is user host admin.
 /// </returns>
 protected bool IsUserHostAdmin([NotNull] DataRow userRow)
 {
     var userFlags = new UserFlags(userRow["Flags"]);
     return userFlags.IsHostAdmin;
 }
Exemple #2
0
        /// <summary>
        /// The bind data.
        /// </summary>
        private void BindData()
        {
            this.RankID.DataSource = CommonDb.rank_list(PageContext.PageModuleID, this.PageContext.PageBoardID, null);
            this.RankID.DataValueField = "RankID";
            this.RankID.DataTextField = "Name";
            this.RankID.DataBind();

            using (
                DataTable dt = CommonDb.user_list(
                    PageContext.PageModuleID, 
                    this.PageContext.PageBoardID,
                    this.CurrentUserId, 
                    null))
            {
                DataRow row = dt.Rows[0];
                var userFlags = new UserFlags(row["Flags"]);

                this.Name.Text = (string)row["Name"];
                this.DisplayName.Text = row.Field<string>("DisplayName");
                this.Email.Text = row["Email"].ToString();
                this.IsHostAdminX.Checked = userFlags.IsHostAdmin;
                this.IsApproved.Checked = userFlags.IsApproved;
                this.IsGuestX.Checked = userFlags.IsGuest;
                this.IsCaptchaExcluded.Checked = userFlags.IsCaptchaExcluded;
                this.IsExcludedFromActiveUsers.Checked = userFlags.IsActiveExcluded;
                this.Joined.Text = row["Joined"].ToString();
                this.IsFacebookUser.Checked = row["IsFacebookUser"].ToType<bool>();
                this.IsTwitterUser.Checked = row["IsTwitterUser"].ToType<bool>();
                this.LastVisit.Text = row["LastVisit"].ToString();
                ListItem item = this.RankID.Items.FindByValue(row["RankID"].ToString());

                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// The save_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            // Update the Membership
            if (!this.IsGuestX.Checked)
            {
                string emailx = this.Email.Text.Trim();

                MembershipUser user = UserMembershipHelper.GetUser(this.Name.Text.Trim());

                // var usr = new CombinedUserDataHelper(user);
                string userName = this.Get<MembershipProvider>().GetUserNameByEmail(emailx);
                if ((userName != null && userName != user.UserName) 
                    || this.Get<YafBoardSettings>().ForumEmail == emailx)
                {
                    this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"));
                    return;
                }

                if (user.Email != emailx)
                {
                    // update the e-mail here too...
                    user.Email = emailx;
                }

                // Update IsApproved
                user.IsApproved = this.IsApproved.Checked;

                this.Get<MembershipProvider>().UpdateUser(user);
            }
            else
            {
                if (!this.IsApproved.Checked)
                {
                    this.PageContext.AddLoadMessage(this.Get<ILocalization>()
                        .GetText("ADMIN_EDITUSER", "MSG_GUEST_APPROVED"));
                    return;
                }
            }

            var userFlags = new UserFlags
            {
                IsHostAdmin = this.IsHostAdminX.Checked,
                IsGuest = this.IsGuestX.Checked,
                IsCaptchaExcluded = this.IsCaptchaExcluded.Checked,
                IsActiveExcluded = this.IsExcludedFromActiveUsers.Checked,
                IsApproved = this.IsApproved.Checked
            };

            CommonDb.user_adminsave(
                PageContext.PageModuleID, 
                this.PageContext.PageBoardID,
                this.CurrentUserId,
                this.Name.Text.Trim(),
                this.DisplayName.Text.Trim(),
                this.Email.Text.Trim(),
                userFlags.BitValue,
                this.RankID.SelectedValue);

            this.Get<IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserId));

            this.BindData();
        }
        /// <summary>
        /// Updates the User Info
        /// </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)
        {
            // Update the Membership
            if (!this.IsGuestX.Checked)
            {
                MembershipUser user = UserMembershipHelper.GetUser(this.Name.Text.Trim());

                string userName = this.Get<MembershipProvider>().GetUserNameByEmail(this.Email.Text.Trim());
                if (userName.IsSet() && userName != user.UserName)
                {
                    this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_EMAIL"), MessageTypes.Warning);
                    return;
                }

                if (this.Email.Text.Trim() != user.Email)
                {
                    // update the e-mail here too...
                    user.Email = this.Email.Text.Trim();
                }

                // Update IsApproved
                user.IsApproved = this.IsApproved.Checked;

                this.Get<MembershipProvider>().UpdateUser(user);
            }
            else
            {
                if (!this.IsApproved.Checked)
                {
                    this.PageContext.AddLoadMessage(
                        this.Get<ILocalization>().GetText("ADMIN_EDITUSER", "MSG_GUEST_APPROVED"), MessageTypes.Success);
                    return;
                }
            }

            var userFlags = new UserFlags
                                {
                                    IsHostAdmin = this.IsHostAdminX.Checked,
                                    IsGuest = this.IsGuestX.Checked,
                                    IsCaptchaExcluded = this.IsCaptchaExcluded.Checked,
                                    IsActiveExcluded = this.IsExcludedFromActiveUsers.Checked,
                                    IsApproved = this.IsApproved.Checked
                                };

            LegacyDb.user_adminsave(
                this.PageContext.PageBoardID,
                this.CurrentUserID,
                this.Name.Text.Trim(),
                this.DisplayName.Text.Trim(),
                this.Email.Text.Trim(),
                userFlags.BitValue,
                this.RankID.SelectedValue);

            this.Get<IRaiseEvent>().Raise(new UpdateUserEvent(this.CurrentUserID));

            this.BindData();
        }