Ejemplo n.º 1
0
        /// <summary>
        /// Handles the ItemCommand event of the UserList control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        public void UserList_ItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "edit":
                YafBuildLink.Redirect(ForumPages.admin_edituser, "u={0}", e.CommandArgument);
                break;

            case "resendEmail":
                var commandArgument = e.CommandArgument.ToString().Split(';');

                var checkMail = this.GetRepository <CheckEmail>().ListTyped(commandArgument[0]).FirstOrDefault();

                if (checkMail != null)
                {
                    var verifyEmail = new YafTemplateEmail("VERIFYEMAIL");

                    var subject = this.Get <ILocalization>()
                                  .GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get <YafBoardSettings>().Name);

                    verifyEmail.TemplateParams["{link}"] = YafBuildLink.GetLinkNotEscaped(
                        ForumPages.approve,
                        true,
                        "k={0}",
                        checkMail.Hash);
                    verifyEmail.TemplateParams["{key}"]       = checkMail.Hash;
                    verifyEmail.TemplateParams["{forumname}"] = this.Get <YafBoardSettings>().Name;
                    verifyEmail.TemplateParams["{forumlink}"] = YafForumInfo.ForumURL;

                    verifyEmail.SendEmail(new MailAddress(checkMail.Email, commandArgument[1]), subject, true);

                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_MESSAGE_SEND"));
                }

                break;

            case "delete":
                var daysValue =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValue))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteUser(e.CommandArgument.ToType <int>());
                }

                LegacyDb.user_delete(e.CommandArgument);
                this.BindData();
                break;

            case "approve":
                UserMembershipHelper.ApproveUser(e.CommandArgument.ToType <int>());
                this.BindData();
                break;

            case "deleteall":

                // vzrus: Should not delete the whole providers portal data? Under investigation.
                var daysValueAll =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValueAll))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteAllUnapproved(DateTime.UtcNow.AddDays(-daysValueAll.ToType <int>()));
                }

                LegacyDb.user_deleteold(this.PageContext.PageBoardID, daysValueAll.ToType <int>());
                this.BindData();
                break;

            case "approveall":
                UserMembershipHelper.ApproveAll();

                // vzrus: Should delete users from send email list
                LegacyDb.user_approveall(this.PageContext.PageBoardID);
                this.BindData();
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the ItemCommand event of the UserList control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        public void UserList_ItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "edit":
                YafBuildLink.Redirect(ForumPages.admin_edituser, "u={0}", e.CommandArgument);
                break;

            case "delete":
                string daysValue =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValue))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteUser(e.CommandArgument.ToType <int>());
                }

                LegacyDb.user_delete(e.CommandArgument);
                this.Get <ILogger>()
                .Log(
                    this.PageContext.PageUserID,
                    "YAF.Pages.Admin.admin",
                    "User {0} was deleted by {1}.".FormatWith(e.CommandArgument.ToType <int>(), this.PageContext.PageUserID),
                    EventLogTypes.UserDeleted);
                this.BindData();
                break;

            case "approve":
                UserMembershipHelper.ApproveUser(e.CommandArgument.ToType <int>());
                this.BindData();
                break;

            case "deleteall":

                // vzrus: Should not delete the whole providers portal data? Under investigation.
                string daysValueAll =
                    this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim();
                if (!ValidationHelper.IsValidInt(daysValueAll))
                {
                    this.PageContext.AddLoadMessage(this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"));
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteAllUnapproved(DateTime.UtcNow.AddDays(-daysValueAll.ToType <int>()));
                }

                LegacyDb.user_deleteold(this.PageContext.PageBoardID, daysValueAll.ToType <int>());
                this.BindData();
                break;

            case "approveall":
                UserMembershipHelper.ApproveAll();

                // vzrus: Should delete users from send email list
                LegacyDb.user_approveall(this.PageContext.PageBoardID);
                this.BindData();
                break;
            }
        }