Beispiel #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 UserListItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "edit":
                BuildLink.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 TemplateEmail("VERIFYEMAIL");

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

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

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

                    this.PageContext.AddLoadMessage(
                        this.GetText("ADMIN_ADMIN", "MSG_MESSAGE_SEND"),
                        MessageTypes.success);
                }
                else
                {
                    var userFound = this.Get <IUserDisplayName>().Find(commandArgument[1]).FirstOrDefault();

                    var user = this.Get <MembershipProvider>().GetUser(userFound.Name, false);

                    this.Get <ISendNotification>().SendVerificationEmail(user, commandArgument[0], userFound.ID);
                }

                break;

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

                this.GetRepository <User>().Delete(e.CommandArgument.ToType <int>());

                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"),
                        MessageTypes.warning);
                    return;
                }

                if (!Config.IsAnyPortal)
                {
                    UserMembershipHelper.DeleteAllUnapproved(DateTime.UtcNow.AddDays(-daysValueAll.ToType <int>()));
                }
                else
                {
                    this.GetRepository <User>().DeleteOld(this.PageContext.PageBoardID, daysValueAll.ToType <int>());
                }

                this.BindData();
                break;

            case "approveall":
                UserMembershipHelper.ApproveAll();

                // vzrus: Should delete users from send email list
                this.GetRepository <User>().ApproveAll(this.PageContext.PageBoardID);
                this.BindData();
                break;
            }
        }
Beispiel #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;
            }
        }