Example #1
0
        /// <summary>
        /// this method removes user of task
        /// </summary>
        /// <param name="task"></param>
        /// <param name="userId"></param>
        /// <param name="alert"></param>
        private void RemoveUserOfTask(Task task, Int32 userId, Alert alert)
        {
            alert = alert ?? new Alert();
            if (alert.AlertId == 0)
            {
                //
                // Send Alert to Creator Task
                //
                var manager = new MembershipManager(this);
                alert.UserId      = task.CreatorUserId;
                alert.Description = alert.Description ?? String.Format(
                    "<b>{0}</b> concluiu sua parte na tarefa " +
                    CreateTaskHtmlLink(task) + "!",
                    manager.GetUser(userId).Profile.AbreviatedName);

                new AlertManager(this).InsertAlert(alert);
            }

            foreach (Task childTask in task.Tasks)
            {
                RemoveUserOfTask(childTask, userId, alert);
            }

            DbContext.TaskUsers.DeleteAllOnSubmit(
                DbContext.TaskUsers.Where(taskUser => taskUser.TaskId == task.TaskId && taskUser.UserId == userId));
            DbContext.SubmitChanges();
        }
Example #2
0
    private void LoadUser()
    {
        User user = MembershipManager.GetUser(Convert.ToInt32(Page.ViewState["UserId"]));

        // load the profile data
        ucProfile.ProfileEntity = ProfileManager.GetProfileByUser(Convert.ToInt32(Page.ViewState["UserId"]));

        chkHasChangePassword.Checked = user.HasChangePassword;

        var representantUser = RepresentantManager.GetRepresentantUser(Convert.ToInt32(Page.ViewState["UserId"]));

        if (representantUser != null)
        {
            cboRepresentant.SelectedValue = Convert.ToString(representantUser.RepresentantId);
        }

        chkIsActiveCheckBox.Checked        = user.IsActive;
        chkIsLockedOut.Checked             = user.IsLockedOut;
        txtUserName.Text                   = user.UserName;
        txtPassword.ValidationGroup        = "dummy";
        txtConfirmPassword.ValidationGroup = "dummy";

        Deposit deposit = CompanyManager.GetCurrentDeposit(Convert.ToInt32(Page.ViewState["UserId"]), Company.CompanyId);

        if (deposit != null)
        {
            cboDeposit.SelectedValue = deposit.DepositId.ToString();
        }
    }
Example #3
0
        protected void uxSave_Click(object sender, EventArgs e)
        {
            var guid = Guid.Empty.ToString();

            if (!string.IsNullOrEmpty(Request.QueryString["guid"]))
            {
                guid = Request.QueryString["guid"].ToString();
            }

            ResetPasswordTicket ResetTicket = new ResetPasswordTicket(guid);
            string password = string.Empty;

            // TODO: Add validation that passwords match

            if (uxPassword.Text == uxPasswordConfirm.Text && !string.IsNullOrEmpty(uxPasswordConfirm.Text))
            {
                ResetTicket.CompleteTicket(Request.UserHostAddress);
                password = uxPassword.Text;
                ResetYourPasswordItem context = (ResetYourPasswordItem)Sitecore.Context.Item;
                var membershipManager         = new MembershipManager();
                var reset = membershipManager.ResetPassword(Guid.Parse(ResetTicket.UserID), password);



                uxMessage.Text = context.PasswordUpdatedText;

                var member = membershipManager.GetMember(Guid.Parse(ResetTicket.UserID));
                var user   = membershipManager.GetUser(Guid.Parse(ResetTicket.UserID), false);
                ExactTargetService.InvokeEM23PasswordResetConfirmation(new InvokeEM23PasswordResetConfirmationRequest {
                    PreferredLanguage = member.PreferredLanguage, EmailAddress = user.Email, ReportChangedPasswordLink = "#", ToEmail = user.Email, UserPassword = "******", RequestUrl = Request.Url
                });
            }
        }
Example #4
0
 public static string GetDisplayUserId(string userId)
 {
     if (userId == null || userId.Length == 0)
     {
         return("[" + Anonymous + "]");
     }
     else
     {
         User user = MembershipManager.GetUser(userId);
         return(GetPersonDisplayName(user));
     }
 }
        private void doLogin()
        {
            //blow out any existing member when someone tries to sign in
            try
            {
                //Reset session backed my groups from Whats Happening Now
                Session["_selectedGroups"] = null;

                //lets make sure to reset all user&member info before we start inflating it
                this.FlushCurrentMemberUser();

                var membershipManager = new MembershipManager();

                var currentMember = new Member();

                if (!string.IsNullOrEmpty(AccessToken))
                {
                    var     client = new Facebook.FacebookClient(AccessToken);
                    dynamic me     = client.Get("me", new { fields = "email" });

                    currentMember = membershipManager.GetMember(me.email);
                }
                else
                {
                    currentMember = membershipManager.AuthenticateUser(uxEmailAddress.Text, uxPassword.Text);
                }

                if (currentMember != null)
                {
                    this.CurrentMember = currentMember;
                    this.CurrentUser   = membershipManager.GetUser(currentMember.MemberId, true);

                    this.ProfileRedirect(Constants.UserPermission.AgreedToTerms, null, true);

                    //Redirect used here for profile??
                    this.ReturnRedirect();

                    var item = Sitecore.Context.Database.GetItem(Constants.Pages.MyAccount);
                    // if you get this far, clear the redirect session URL

                    Response.Redirect(Sitecore.Links.LinkManager.GetItemUrl(item));
                }
            }
            catch (Exception ex)
            {
                uxError.Text = ex.Message;
            }
        }
Example #6
0
        private void updateMember()
        {
            var membershipManager = new MembershipManager();

            try
            {
                //set current user/member
                this.CurrentMember = membershipManager.UpdateMember(this.registeringUser);

                if (mode != Constants.QueryStrings.Registration.ModeEdit)
                {
                    this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId);


                    //SalesforceManager sfMgr = new SalesforceManager("*****@*****.**",
                    //                                                 "8f9C3Ayq",
                    //                                                 "hlY0jOIILtogz3sQlLUtmERlu");

                    SalesforceManager sfMgr = new SalesforceManager(Constants.SALESFORCE_USERNAME,
                                                                    Constants.SALESFORCE_PASSWORD,
                                                                    Constants.SALESFORCE_TOKEN);
                    if (sfMgr.LoggedIn)
                    {
                        try
                        {
                            SalesforceActionResult result = sfMgr.CreateWebsiteMemberAsContact(this.CurrentMember, CurrentUser.Email);
                            if (result.Success == false)
                            {
                                Response.Write("<!-- Error 401 -->");
                            }
                        }
                        catch (Exception)
                        {
                            Response.Write("<!-- Error 501 -->");
                        }
                    }
                    else
                    {
                        Response.Write("<!-- Error 601 -->");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        private void ProcessEmail()
        {
            // TODO: validate email
            string            email      = txtEmail.Text.Trim();
            MembershipManager mm         = new MembershipManager();
            MembershipUser    subscriber = mm.GetUser(email);

            if (subscriber != null && subscriber.Comment != Constants.UnauthenticatedMember_Flag)
            {
                litErrorMessage.Text = Model.UnauthenticatedMemberError.Rendered;
            }
            else
            {
                // temporarily skip personalized questions
                if (subscriber == null)
                {
                    Member member = new Member
                    {
                        Email           = email,
                        allowNewsletter = true
                    };

                    mm.AddUnauthorizedMember(member);
                    mm.UpdateMember_ExtendedProperties(member);
                }
                else
                {
                    Member member = mm.GetMember(email);
                    member.allowNewsletter = true;
                    mm.UpdateMember(member);
                }

                RedirectToConfirmation();

                /*
                 * Submission submission = new Submission
                 * {
                 *  Email = email
                 * };
                 *
                 * Session[Constants.SessionNewsletterKey] = submission;
                 *
                 * var item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(Constants.Pages.NewsletterChildInfo.ToString()));
                 * Response.Redirect(item.GetUrl());*/
            }
        }
        protected void rptComments_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Comment comment    = (Comment)e.Item.DataItem;
                Panel   pnlAuthor  = (Panel)e.FindControlAs <Panel>("pnlAuthor");
                Panel   pnlComment = (Panel)e.FindControlAs <Panel>("pnlComment");

                HyperLink       hlTitle = e.FindControlAs <HyperLink>("hlTitle");
                ContentPageItem item    = Sitecore.Context.Database.GetItem(comment.SitecoreId);
                if (item != null)
                {
                    hlTitle.NavigateUrl = item.GetUrl();
                    hlTitle.Text        = item.PageTitle.Rendered;
                }

                Literal litDate = e.FindControlAs <Literal>("litDate");
                litDate.Text = UnderstoodDotOrg.Common.Helpers.DataFormatHelper.FormatDate(comment.CommentDate);

                Literal litComment = e.FindControlAs <Literal>("litComment");
                litComment.Text = UnderstoodDotOrg.Common.Helpers.TextHelper.TruncateText(
                    Sitecore.StringUtil.RemoveTags(HttpUtility.HtmlDecode(comment.Body)), commentCharLimit);

                Literal litLikeCount = e.FindControlAs <Literal>("litLikeCount");
                litLikeCount.Text = comment.Likes;

                if (e.Item.ItemIndex == 0 && DisplayAuthorInfo && ProfileMember != null)
                {
                    pnlAuthor.Visible = true;

                    Literal litScreenName = e.FindControlAs <Literal>("litScreenName");
                    litScreenName.Text = ProfileMember.ScreenName;

                    Literal           litLastUpdated = e.FindControlAs <Literal>("litLastUpdated");
                    MembershipManager mm             = new MembershipManager();
                    var user = mm.GetUser(ProfileMember.MemberId);
                    litLastUpdated.Text = user.LastActivityDate.ToString("hh:mmtt on MMM dd yyyy");
                }
                else
                {
                    pnlComment.CssClass += " offset-6";
                }
            }
        }
Example #9
0
    protected void btnActivate_Click(object sender, EventArgs e)
    {
        try
        {
            MembershipManager manager = new MembershipManager(this);
            int result = 0;
            var user   = Int32.TryParse(ActivationCode.Text, out result) ? manager.GetUser(result) : manager.GetUserByEmail(ActivationCode.Text);

            if (user != null)
            {
                manager.UnlockUser(user.UserName);
            }

            MultiView1.ActiveViewIndex = (int)Actions.Login;
        }
        catch (Exception ex)
        {
            MultiView1.ActiveViewIndex = (int)Actions.Activation;
            lblActivationError.Text    = "Código de Ativação incorreto!";
            lblActivationError.Visible = true;
        }
    }
Example #10
0
        public static void CreatePerson(string lastName, string firstName, Address address)
        {
            if (string.IsNullOrEmpty(lastName))
            {
                throw new ArgumentNullException("lastName");
            }
            if (string.IsNullOrEmpty(firstName))
            {
                throw new ArgumentNullException("firstName");
            }
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            if (string.IsNullOrEmpty(address.Id))
            {
                AddressManager.CreateAddress(address);
                address = AddressManager.GetAddressByDetails(address.Address1, address.Address2, address.Suburb,
                                                             address.Postcode, address.State);
            }

            var person = new Person();

            person.FirstName = firstName;
            person.LastName  = lastName;
            person.Address   = address;

            // todo figure out a better default username.
            string         defaultName    = firstName + lastName;
            MembershipUser membershipUser = System.Web.Security.Membership.CreateUser(defaultName, defaultName);

            if (membershipUser.ProviderUserKey != null)
            {
                User user = MembershipManager.GetUser(membershipUser.ProviderUserKey.ToString());
                Provider.CreatePerson(person, user);
            }
        }
        /// <summary>
        /// This method updates an user
        /// </summary>
        /// <param name="userId">Can't be null</param>
        /// <param name="companyId">Can't be null</param>
        /// <param name="depositId"></param>
        /// <param name="user">Can't be null</param>
        public void UpdateUser(int userId, int companyId, int? depositId, User user)
        {
            //
            // Save User
            //
            var mManager = new MembershipManager(this);

            User original_user = mManager.GetUser(userId);

            mManager.Update(original_user, user);
            //
            // Deposit
            //
            ChangeDeposit(companyId, userId, depositId);

            //
            // Associate the User with company
            //
            if (GetCompanyUser(companyId, userId) == null)
                AssociateUser(companyId, userId, depositId, true);
        }
 /// <summary>
 /// This method delete a user
 /// </summary>
 /// <param name="newUser"></param>
 public void DeleteUser(User newUser)
 {
     var membershipManager = new MembershipManager(this);
     newUser = membershipManager.GetUser(newUser.UserId);
     membershipManager.Delete(newUser);
 }
        private void Page_Load(object sender, EventArgs e)
        {
            if (this.CurrentMember == null && this.CurrentUser == null)
            {
                if (!string.IsNullOrEmpty(CurrentPage.SignInPage.Url))
                {
                    Response.Redirect(CurrentPage.SignInPage.Url);
                }
                else
                {
                    Response.Redirect("/");
                }
            }

            if (!IsPostBack)
            {
                //update member
                MembershipManager membershipManager = new MembershipManager();
                this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                this.CurrentUser   = membershipManager.GetUser(this.CurrentMember.MemberId, true);

                MyProfileItem context = (MyProfileItem)Sitecore.Context.Item;
                HyperLink     myHL    = (HyperLink)this.FindControl("uxAddChild");
                myHL.Text = context.AddChildText;

                SetLabels();
                SetRole();

                uxChildList.DataSource = this.CurrentMember.Children;
                uxChildList.DataBind();

                //disable new children if you already have 6 or more
                if (this.CurrentMember.Children.Count >= 6)
                {
                    uxAddChild.Visible = false;
                }

                SetInterests();

                uxEmailAddress.Text = txtEmail.Text = this.CurrentUser.UserName;


                SetJourney();

                uxPassword.Text = replacePassword("digitalpulp!");

                string phoneNumber = string.Empty;

                if (!string.IsNullOrEmpty(this.CurrentMember.MobilePhoneNumber))
                {
                    phoneNumber = this.CurrentMember.MobilePhoneNumber.Replace("-", string.Empty).Trim();

                    //if (phoneNumber.Length == 10 && !phoneNumber.Contains("-"))
                    //{
                    phoneNumber = phoneNumber.Insert(3, "-");
                    phoneNumber = phoneNumber.Insert(7, "-");
                    //}
                }
                else
                {
                    //10 points to Gryffindor if you know where this phone number comes from
                    txtPhoneNumber.Attributes["placeholder"] = "212-555-2368";
                }

                uxPhoneNumber.Text  = phoneNumber;
                txtPhoneNumber.Text = phoneNumber;

                uxPrivacyLevel.Text = this.CurrentMember.allowConnections ? DictionaryConstants.OpenToConnect : DictionaryConstants.NotOpenToConnect;

                uxScreenname.Text = this.CurrentMember.ScreenName;

                uxZipcode.Text = this.CurrentMember.ZipCode.Trim();

                uxAddChild.Text        = string.Format(uxAddChild.Text, ((ChildCount)this.CurrentMember.Children.Count).ToString());
                uxAddChild.NavigateUrl = MyProfileStepTwoItem.GetCompleteMyProfileStepTwo().GetUrl() + "?" + Constants.QueryStrings.Registration.Mode + "=" + Constants.QueryStrings.Registration.ModeAdd;

                if (Session["PostReloadScript"] != null)
                {
                    string reloadScript = Session["PostReloadScript"].ToString();

                    if (reloadScript != "")
                    {
                        ltlJS.Text = string.Format("<script type=\"text/javascript\">{0}</script>", reloadScript);
                        Session["PostReloadScript"] = null;
                    }
                }

                //top of edit interests
                hypEditCommunityAboutMe.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                //jump to edit community
                hypEditCommunity.NavigateUrl = hypCompleteYourProfile.NavigateUrl = String.Format(MyProfileStepFourItem.GetCompleteMyProfileStepFour().GetUrl() + "?{0}={1}#community", Constants.QueryStrings.Registration.Mode, Constants.QueryStrings.Registration.ModeEdit);

                if (!string.IsNullOrEmpty(this.CurrentMember.ScreenName))
                {
                    hypViewAsVisitors.NavigateUrl = MembershipHelper.GetPublicProfileAsVisitorUrl(CurrentMember.ScreenName);
                    hypViewAsMembers.NavigateUrl  = MembershipHelper.GetPublicProfileAsMemberUrl(CurrentMember.ScreenName);
                    hypViewAsFriends.NavigateUrl  = MembershipHelper.GetPublicProfileUrl(CurrentMember.ScreenName);
                }
                else
                {
                    uxNoProfile.Visible  = true;
                    uxPublicView.Visible = false;
                }
            }
        }
        protected void lbSaveEmailPassword_Click(object sender, EventArgs e)
        {
            var action = false;

            try
            {
                if (!string.IsNullOrEmpty(this.txtEmail.Text))
                {
                    if (Regex.IsMatch(this.txtEmail.Text, Constants.Validators.Email))
                    {
                        //matched regex
                        if (this.UpdateEmail())
                        {
                            action = true;

                            var membershipManager = new MembershipManager();

                            this.CurrentMember = membershipManager.GetMember(this.CurrentMember.MemberId);
                            this.CurrentUser   = membershipManager.GetUser(this.CurrentMember.MemberId, true);
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //did not match regex and not empty
                        throw new Exception(DictionaryConstants.PasswordErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }

            try
            {
                if (!string.IsNullOrEmpty(this.txtOldPassword.Text) && !string.IsNullOrEmpty(this.txtNewPassword.Text) && !string.IsNullOrEmpty(this.txtConfirmNewPassword.Text))
                {
                    if (this.txtNewPassword.Text == this.txtConfirmNewPassword.Text &&
                        Regex.IsMatch(this.txtNewPassword.Text, Constants.Validators.Password) &&
                        Regex.IsMatch(this.txtOldPassword.Text, Constants.Validators.Password))
                    {
                        if (this.UpdatePassword())
                        {
                            action = true;
                        }
                        else
                        {
                            throw new Exception(DictionaryConstants.SomethingFailedError);
                        }
                    }
                    else
                    {
                        //new passwords don't match
                        throw new Exception(DictionaryConstants.PasswordMatchError);
                    }
                }
            }
            catch (Exception ex)
            {
                litEmailPasswordError.Text += ex.Message;
            }


            if (action)
            {
                Response.Redirect(Request.RawUrl, true);
            }
        }
Example #15
0
    protected void btCreateAdmin_Click(object sender, EventArgs e)
    {
        // Create a person type, and a role, and a persontyperole.
        PersonType adminPersonType = new PersonType();

        adminPersonType.Name = BusiBlocks.BusiBlocksConstants.AdministratorsGroup;
        var personTypes = PersonManager.GetAllPersonTypes(true).FirstOrDefault(x => x.Name.Equals(adminPersonType.Name));

        if (personTypes == null)
        {
            PersonManager.CreatePersonType(adminPersonType);
        }
        adminPersonType = PersonManager.GetAllPersonTypes(true).FirstOrDefault(x => x.Name.Equals(adminPersonType.Name));
        Role role = RoleManager.GetRoleByName(txtAdminRole.Text);

        if (role == null)
        {
            Roles.CreateRole(txtAdminRole.Text);
        }
        PersonTypeRole personTypeRole = new PersonTypeRole();

        personTypeRole.PersonType = adminPersonType;
        Role role1 = RoleManager.GetRoleByName(txtAdminRole.Text);

        personTypeRole.Role = role1;
        var personTypeRole1 = PersonManager.GetAllPersonTypeRoles().FirstOrDefault(x => (x.Role.Name.Equals(role1.Name) && x.PersonType.Name.Equals(personTypeRole.PersonType.Name)));

        if (personTypeRole1 == null)
        {
            PersonManager.CreatePersonTypeRole(personTypeRole);
        }

        string pwd = txtAdminPassword.Text;

        MembershipUser user2 = Membership.GetUser(txtAdminUser.Text);

        if (user2 == null)
        {
            Membership.CreateUser(txtAdminUser.Text, pwd, txtAdminEMail.Text);
        }
        MembershipUserCollection col     = Membership.FindUsersByName(txtAdminUser.Text);
        MembershipUser           memUser = col[txtAdminUser.Text];
        User user = MembershipManager.GetUser(memUser.ProviderUserKey.ToString());

        var roles1 = RoleManager.GetRolesByUser(user).FirstOrDefault(x => x.Name.Equals(role1.Name));

        if (roles1 == null)
        {
            RoleManager.AddUserToRole(user, role1);
        }

        // Find a Person who matches this User.
        // If none exists, create one.
        string userName = txtAdminUser.Text;
        Person person   = PersonManager.GetPersonByUserName(userName);

        if (person == null)
        {
            Address address1 = new Address();
            address1.Address1 = "1 Admin Drive";
            AddressManager.CreateAddress(address1);
            User user1 = MembershipManager.GetUserByName(userName);
            PersonManager.CreatePerson(user1, userName, address1);
            person = PersonManager.GetPersonByUserId(user1.Id);
        }
        var personType1 = PersonManager.GetPersonTypesByPerson(person).FirstOrDefault(x => x.Name.Equals(adminPersonType.Name));

        if (personType1 == null)
        {
            PersonManager.AddPersonToPersonType(person.Id, adminPersonType.Id);
        }

        lblStatus.InnerText = "User created!";
    }
Example #16
0
    private void BindPageEditItem()
    {
        divSaveFunctions.Visible = true;
        btnDelete.Visible        = true;

        VersionItem version = VersionManager.GetVersionById(VersionId);
        Item        item    = (version == null) ? NewsManager.GetItem(ItemId) : NewsManager.GetItem(version.ItemId);

        txtDescription.Content = item.Description;
        txtTitle.Text          = item.Title;
        lblTitle.Text          = item.Title;
        ddlOwner.SelectedIndex = ddlOwner.Items.IndexOf(ddlOwner.Items.FindByText(item.Owner));

        //rdpExpiry.SelectedDate = item.Expiry;
        lnkVersionNumber.Text        = "Version&nbsp;" + ((version == null) ? VersionManager.GetVersionNumber(VersionType.New, string.Empty) : VersionManager.GetVersionNumber(VersionType.Draft, version.ItemId));
        lnkVersionNumber.NavigateUrl = (version == null) ? null : Navigation.Communication_NewsVersionHistory(version.GroupId).GetServerUrl(true);

        // Set the acknowledge radios.
        if (item.RequiresAck)
        {
            rblAcknowledge.Items.FindByValue("required").Selected = true;
            ackReqd.CssClass = "";
            rblAcknowledge.Items.FindByValue("notRequired").Selected = false;
            ackNotReqd.CssClass = "hideElement";
        }
        else
        {
            rblAcknowledge.Items.FindByValue("required").Selected = false;
            ackReqd.CssClass = "hideElement";
            rblAcknowledge.Items.FindByValue("notRequired").Selected = true;
            ackNotReqd.CssClass = "";
        }
        // Set the approval radios.
        if (item.RequiresApproval)
        {
            rblApproval.Items.FindByValue("required").Selected    = true;
            rblApproval.Items.FindByValue("notRequired").Selected = false;
        }
        else
        {
            rblApproval.Items.FindByValue("required").Selected    = false;
            rblApproval.Items.FindByValue("notRequired").Selected = true;
        }

        //pre selecting the major/minor
        if (version == null)
        {
            //rblEditDetails.Items.FindByText("minor").Selected = true;
            trEditDetails.Visible = false;
        }
        else
        {
            //check if there's any published version - true =use the previous severity value else set it to major as first published will always be null.
            Item tempItem = NewsManager.GetPublishedItem(version.GroupId);
            if (tempItem.Id != null)
            {
                if (!string.IsNullOrEmpty(version.EditSeverity))
                {
                    rblEditDetails.Items.FindByValue(version.EditSeverity).Selected = true;
                }
                else
                {
                    rblEditDetails.Items.FindByValue("minor").Selected = true;
                }
            }
            else
            {
                trEditDetails.Visible = false;
            }
        }
        //Load permissions
        pmm.LoadPermissionsView(item.Category.Id, item.Category.Name);

        //if user is approver then show the minor/major option.
        lblPageHeading.Text = TitleEdit;

        //select the approver item only if theres a version existing.
        if (version != null)
        {
            IList <Approver> approvers = ApproverManager.GetApproversByItem(version.Id);
            //count more than one means its a category approval
            if (approvers.Count != 0 && ddlApprovers.Enabled != false)
            {
                if (!string.IsNullOrEmpty(approvers[0].UserId))
                {
                    string ddlValue = MembershipManager.GetUser(approvers[0].UserId).Name;
                    ddlApprovers.Items.FindByText(ddlValue).Selected = true;
                }
                else if (ddlApprovers.Items.Count > 0)
                {
                    ddlApprovers.Items[0].Selected = true;
                }
            }

            bool isAckReq = NewsManager.GetItem(version.ItemId).RequiresAck;
            if (isAckReq)
            {
                BindAcknowledgeCount(version.ItemId, version.GroupId, version.VersionNumber);
                BindViewerCount(null, null);
            }
            else
            {
                BindViewerCount(version.GroupId, version.VersionNumber);
                BindAcknowledgeCount(null, null, null);
            }
        }
    }
        protected void uxSubmit_Click(object sender, EventArgs e)
        {
            // server-side validation
            string name     = string.Empty;
            string email    = string.Empty;
            string password = string.Empty;

            string zip            = uxZipCode.Text.RemoveHTML();
            bool   newsletter     = uxNewsletterSignup.Checked;
            bool   isFacebookUser = !string.IsNullOrEmpty(AccessToken);

            if (!string.IsNullOrEmpty(uxFirstName.Text))
            {
                name = uxFirstName.Text.RemoveHTML();
            }

            if (!string.IsNullOrEmpty(uxEmailAddress.Text))
            {
                email = uxEmailAddress.Text;
            }

            if (isFacebookUser)
            {
                password = Constants.FacebookMember_Password;
            }
            else if (!string.IsNullOrEmpty(uxPassword.Text) && !string.IsNullOrEmpty(uxPasswordConfirm.Text) && uxPassword.Text == uxPasswordConfirm.Text)
            {
                password = uxPassword.Text;
            }

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                // damnit barry, this is how you get ants.
                // the site keeps breaking when we test, and its breaking ugly.
                // if someone clicks to create a new user, we have to blow up the existing user or we're going to have a problem.
                this.FlushRegisteringUser();

                //everything's cool
                if (this.registeringUser == null)
                {
                    this.registeringUser = new Domain.Membership.Member();
                }

                this.registeringUser.FirstName = name;

                //bg: adding in zip code
                this.registeringUser.ZipCode = zip.Trim();

                //adding marker for FB users
                this.registeringUser.isFacebookUser = isFacebookUser;

                var membershipManager = new MembershipManager();

                try
                {
                    // helps to call the right addMember method...
                    this.registeringUser = membershipManager.AddMember(this.registeringUser, email, password);
                }
                catch (Exception ex)
                {
                    uxErrorMessage.Text = ex.Message;
                    return;
                }

                this.CurrentMember = this.registeringUser;
                this.CurrentUser   = membershipManager.GetUser(this.CurrentMember.MemberId);

                Response.Redirect(TermsandConditionsItem.GetTermsAndConditionsPage().GetUrl());
            }
            else
            {
                //something failed...
                uxErrorMessage.Text = DictionaryConstants.SomethingFailedError;
            }
        }