예제 #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                PermissionsManager mgr = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
예제 #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                Database.ConnString = Website.Config.PostgreSQLConnectionString;
                Database.DBType     = "MySQL";
                Database.DBPrefix   = "DMG";
                email = Functions.RepairString(email);
                string             password = Functions.Encrypt(Functions.RepairString(CreateUserWizard1.Password));
                PermissionsManager mgr      = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
                //Database.Write("INSERT INTO " + Database.DBPrefix + "_MEMBERS (MEMBER_USERNAME, MEMBER_PASSWORD, MEMBER_LEVEL, MEMBER_EMAIL, MEMBER_LOCATION, MEMBER_HOMEPAGE, MEMBER_SIGNATURE, MEMBER_SIGNATURE_SHOW, MEMBER_IM_AOL, MEMBER_IM_ICQ, MEMBER_IM_MSN, MEMBER_IM_YAHOO, MEMBER_POSTS, MEMBER_DATE_JOINED, MEMBER_DATE_LASTVISIT, MEMBER_TITLE, MEMBER_TITLE_ALLOWCUSTOM, MEMBER_TITLE_USECUSTOM, MEMBER_EMAIL_SHOW, MEMBER_IP_LAST, MEMBER_IP_ORIGINAL, MEMBER_REALNAME, MEMBER_OCCUPATION, MEMBER_SEX, MEMBER_AGE, MEMBER_BIRTHDAY, MEMBER_NOTES, MEMBER_FAVORITESITE, MEMBER_PHOTO, MEMBER_AVATAR, MEMBER_AVATAR_SHOW, MEMBER_AVATAR_ALLOWCUSTOM, MEMBER_AVATAR_USECUSTOM, MEMBER_AVATAR_CUSTOMLOADED, MEMBER_AVATAR_CUSTOMTYPE, MEMBER_VALIDATED, MEMBER_VALIDATION_STRING, MEMBER_RANKING) VALUES ('" + email + "','" + password + "', " + 1 + ", '" + email + "', ' ', ' ', ' ', 0, '', '', '', '', 0, " + Database.GetTimeStamp() + ", " + Database.GetTimeStamp() + ", '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', 1, 0 , 0, 0, 0, 'jpg', 1, '', 0)");
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
예제 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        //UserProfile p = UserProfileDB.GetUserProfileByMembershipUserGUID(memGuid);

        UserProfile p = this.GetCurrentUserProfile();

        bool isNew = (p == null);

        string fName     = this.FirstNameTextBox.Text;
        string lName     = this.LastNameTextBox.Text;
        string email     = this.EmailTextBox.Text;
        string website   = this.WebsiteURLTextBox.Text;
        string sponsName = this.SponsorNameTextBox.Text;
        string devName   = this.DeveloperNameTextBox.Text;
        string artName   = this.ArtistNameTextBox.Text;
        string phone     = this.PhoneTextBox.Text;

        byte[] sponsorLogoByteArray   = null;
        string sponsorLogoContentType = "";
        string sponsorLogoFileName    = "";

        //sponsor logo
        if (this.SponsorLogoFileUpload.PostedFile != null && !String.IsNullOrEmpty(this.SponsorLogoFileUpload.PostedFile.FileName))
        {
            sponsorLogoContentType = this.SponsorLogoFileUpload.PostedFile.ContentType.Trim();
            sponsorLogoFileName    = this.SponsorLogoFileUpload.FileName;

            //check valid content type
            if (Website.Common.IsValidLogoImageContentType(sponsorLogoContentType))
            {
                sponsorLogoByteArray = Website.Common.GetByteArrayFromFileUpload(this.SponsorLogoFileUpload);
            }
            else
            {
                //show error message
                this.EditProfileViewErrorMessageLabel.Text = "Invalid Sponsor Logo file type. Please upload a valid image file";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            //set to current
            if (!isNew)
            {
                if (p.SponsorLogo != null && !string.IsNullOrEmpty(p.SponsorLogoContentType))
                {
                    if (this.RemoveSponsorLogoCheckBox.Checked)
                    {
                        sponsorLogoByteArray   = null;
                        sponsorLogoContentType = string.Empty;
                        sponsorLogoFileName    = string.Empty;
                    }
                    else
                    {
                        //set to current
                        sponsorLogoByteArray   = p.SponsorLogo;
                        sponsorLogoContentType = p.SponsorLogoContentType;
                        sponsorLogoFileName    = p.SponsorLogoFileName;
                    }
                }
            }
        }

        byte[] developerLogoByteArray   = null;
        string developerLogoContentType = null;
        string developerLogoFileName    = "";

        //developer logo
        if (this.DeveloperLogoFileUpload.PostedFile != null && !string.IsNullOrEmpty(this.DeveloperLogoFileUpload.PostedFile.FileName))
        {
            developerLogoContentType = this.DeveloperLogoFileUpload.PostedFile.ContentType.Trim();
            developerLogoFileName    = this.DeveloperLogoFileUpload.FileName;

            //check valid content type
            if (Website.Common.IsValidLogoImageContentType(developerLogoContentType))
            {
                developerLogoByteArray = Website.Common.GetByteArrayFromFileUpload(this.DeveloperLogoFileUpload);
            }
            else
            {
                this.EditProfileViewErrorMessageLabel.Text = "Invalid Developer Logo file type. Please upload a valid image file";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            if (!isNew)
            {
                //set to current
                if (p.DeveloperLogo != null && !string.IsNullOrEmpty(p.DeveloperLogoContentType))
                {
                    if (this.RemoveDeveloperLogoCheckBox.Checked)
                    {
                        //set to null
                        developerLogoByteArray   = null;
                        developerLogoContentType = string.Empty;
                        developerLogoFileName    = string.Empty;
                    }
                    else
                    {
                        //set to current
                        developerLogoByteArray   = p.DeveloperLogo;
                        developerLogoContentType = p.DeveloperLogoContentType;
                        developerLogoFileName    = p.DeveloperLogoFileName;
                    }
                }
            }
        }

        //update
        if (p != null)
        {
            //update
            p.FirstName                = fName;
            p.LastName                 = lName;
            p.Email                    = email;
            p.WebsiteURL               = website;
            p.SponsorName              = sponsName;
            p.DeveloperName            = devName;
            p.ArtistName               = artName;
            p.Phone                    = phone;
            p.SponsorLogo              = sponsorLogoByteArray;
            p.SponsorLogoContentType   = sponsorLogoContentType;
            p.SponsorLogoFileName      = sponsorLogoFileName;
            p.DeveloperLogo            = developerLogoByteArray;
            p.DeveloperLogoContentType = developerLogoContentType;
            p.DeveloperLogoFileName    = developerLogoFileName;

            try
            {
                UserProfileDB.UpdateUserProfile(p, Context.User.Identity.Name);


                if (Website.Security.IsAdministrator())
                {
                    ConfirmationLabel.Text = p.FirstName + " " + p.LastName + " has been successfully updated.";
                }
                else
                {
                    ConfirmationLabel.Text = "Your profile has been successfully updated.";
                }
            }
            catch
            {
                this.EditProfileViewErrorMessageLabel.Text = "Unable to update your profile. Please try again or <a href=" + this.ResolveUrl(Website.Pages.Types.Contact) + " class='Hyperlink'>Contact Us</a> if you have any questions.";
                MultiView1.SetActiveView(EditProfileView);
                return;
            }
        }
        else
        {
            //insert
            if (!Website.Security.IsAdministrator())
            {
                try
                {
                    ////update profile
                    MembershipUser mu = Membership.GetUser(Context.User.Identity.Name.Trim());

                    ////user guid
                    string memGuid = mu.ProviderUserKey.ToString();

                    p = UserProfileDB.InsertUserProfile(memGuid, fName, lName, email, Context.User.Identity.Name, Context.User.Identity.Name, website, sponsName, devName, artName, phone, sponsorLogoByteArray, sponsorLogoContentType, sponsorLogoFileName, developerLogoByteArray, developerLogoContentType, developerLogoFileName);
                    ConfirmationLabel.Text = "Your profile has been successfully created.";
                }
                catch
                {
                    this.EditProfileViewErrorMessageLabel.Text = "Unable to create your profile. Please try again or <a href = Contact.aspx class='Hyperlink'>Contact Us</a> if you have any questions.";
                    MultiView1.SetActiveView(EditProfileView);
                    return;
                }
            }
        }

        MultiView1.SetActiveView(ConfirmationView);
    }