Ejemplo n.º 1
0
 /// <summary>
 /// Fills the invite membership drop down.
 /// </summary>
 private void FillInviteMembershipDropDown()
 {
     if (InviteMembershipDropDown.Items.Count == 0)
     {
         foreach (MembershipLevels level in Enum.GetValues(typeof(MembershipLevels)))
         {
             InviteMembershipDropDown.Items.Add(new ListItem(Membership.TranslateMembershipLevel(level), level.ToString()));
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Handles the Click event of the SaveMembership control to save the changes in membership.
 /// </summary>
 /// <param name="sender">The Save button.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void SaveMembership_Click(object sender, EventArgs e)
 {
     if (_modifiedMembers.Count > 0 && Membership.QueryDistinctMembershipLevel(WorkroomStartPage, MembershipLevels.Administer))
     {
         PageData page = WorkroomStartPage.CreateWritableClone();
         Membership.ModifyPermission(page, _modifiedMembers);
         DataFactory.Instance.Save(page, SaveAction.Publish);
         if (SendNotificationsButton.Checked)
         {
             NotifyUsersByEmailAboutChangedPermissions(_modifiedMembers);
         }
     }
     _modifiedMembers.Clear();
     SetViewMode(ViewMode.ViewMembers);
     DataBindChildren();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the DeleteUserConfirm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void DeleteUserConfirm_Click(object sender, EventArgs e)
        {
            IList <MembershipEntry> deletedMembers = UsersToDelete;

            if (deletedMembers.Count > 0 && Membership.QueryDistinctMembershipLevel(WorkroomStartPage, MembershipLevels.Administer))
            {
                PageData page = WorkroomStartPage.CreateWritableClone();
                Membership.ModifyPermission(page, deletedMembers);
                DataFactory.Instance.Save(page, SaveAction.Publish);
                if (SendNotificationsButton.Checked)
                {
                    NotifyUsersByEmailAboutChangedPermissions(deletedMembers);
                }
            }
            UsersToDelete = null;
            SetViewMode(ViewMode.ViewMembers);
            DataBindChildren();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the DataBinding event of the MembershipLevel control in membership column of the the UserList gridview control.
        /// Used to populate the membership level drop down.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void MembershipLevel_DataBinding(object sender, EventArgs e)
        {
            Control container = (Control)sender;

            // We're inside a data row which is a data item container.
            IDataItemContainer dataContainer = container.BindingContainer as IDataItemContainer;

            if (dataContainer != null)
            {
                // Get the entry we're binding against.
                MembershipEntry userEntry = (MembershipEntry)dataContainer.DataItem;

                if ((ActiveMode == ViewMode.EditMembers && userEntry.Name != Context.User.Identity.Name) || (ActiveMode == ViewMode.AddMembers && userEntry.Membership == MembershipLevels.None))
                {
                    DropDownList membershipDropdown = (DropDownList)container.FindControl("MembershipDropdown");

                    foreach (MembershipLevels level in Enum.GetValues(typeof(MembershipLevels)))
                    {
                        membershipDropdown.Items.Add(new ListItem(Membership.TranslateMembershipLevel(level), userEntry.Name + ":" + level.ToString()));
                    }

                    // Check if the user has been modified but not saved.
                    MembershipEntry modifiedMembership;
                    int             matchIndex = _modifiedMembers.IndexOf(userEntry);
                    if (matchIndex != -1)
                    {
                        modifiedMembership = _modifiedMembers[matchIndex];
                    }
                    else
                    {
                        modifiedMembership = userEntry;
                    }

                    membershipDropdown.SelectedValue = userEntry.Name + ":" + modifiedMembership.Membership.ToString();
                    membershipDropdown.Visible       = true;
                }
                else
                {
                    Literal membershipLiteral = (Literal)container.FindControl("MembershipLiteral");
                    membershipLiteral.Text    = userEntry.MembershipLocalName;
                    membershipLiteral.Visible = true;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the state of the control (visible buttons etc.) according to the new View Mode.
        /// </summary>
        /// <param name="viewMode">The new view mode.</param>
        private void SetViewMode(ViewMode viewMode)
        {
            bool isAdministrator = Membership.QueryDistinctMembershipLevel(WorkroomStartPage, MembershipLevels.Administer);

            if (!isAdministrator)
            {
                viewMode = ViewMode.ViewMembers;
            }

            ActiveMode = viewMode;
            switch (viewMode)
            {
            case ViewMode.ViewMembers:
                ToolBarButtons.Visible                = isAdministrator;
                PersistButtons.Visible                = false;
                ConfirmDeleteButtons.Visible          = false;
                SearchDialog.Visible                  = false;
                ConfirmDeleteButtons.Visible          = false;
                DeleteButton.Visible                  = false;
                DeleteUserDialog.Visible              = false;
                MemberListHeading.Text                = Translate("/workroom/membershipmanager/viewmembersheading");
                SendNotificationsConfirmation.Visible = false;
                break;

            case ViewMode.AddMembers:
                ToolBarButtons.Visible       = false;
                PersistButtons.Visible       = true;
                DeleteButton.Visible         = false;
                SearchDialog.Visible         = true;
                ConfirmDeleteButtons.Visible = false;
                DeleteButton.Visible         = false;
                DeleteUserDialog.Visible     = false;
                MemberListHeading.Text       = Translate("/workroom/membershipmanager/searchresultheading");
                FillInviteMembershipDropDown();
                SendNotificationsConfirmation.Visible = true;
                SendOkPanel.Visible    = false;
                SendErrorPanel.Visible = false;
                SendNotificationsConfirmation.Visible = false;
                break;

            case ViewMode.EditMembers:
                ToolBarButtons.Visible                = false;
                PersistButtons.Visible                = true;
                SearchDialog.Visible                  = false;
                DeleteButton.Visible                  = true;
                ConfirmDeleteButtons.Visible          = false;
                DeleteUserDialog.Visible              = false;
                MemberListHeading.Text                = Translate("/workroom/membershipmanager/managemembersheading");
                SendNotificationsConfirmation.Visible = true;
                break;

            case ViewMode.DeleteMember:
                ToolBarButtons.Visible                = false;
                PersistButtons.Visible                = false;
                DeleteButton.Visible                  = false;
                ConfirmDeleteButtons.Visible          = true;
                DeleteUserDialog.Visible              = true;
                SearchDialog.Visible                  = false;
                MemberListHeading.Text                = Translate("/workroom/membershipmanager/managemembersheading");
                SendOkPanel.Visible                   = false;
                SendErrorPanel.Visible                = false;
                SendNotificationsConfirmation.Visible = true;
                break;
            }

            //Clear search criteria
            UserName.Text = string.Empty;
            Email.Text    = string.Empty;

            // Always clear the collection of modified members,
            // this is only for persisting modifications between changes in paging.
            _modifiedMembers.Clear();
            SetupDeleteUserSelection();
            UserList.PageIndex = 0;
            UserList.DataBind();
        }