/// <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(); }
/// <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(); }
/// <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(); }
/// <summary> /// Gets a value indicating whether the current user has at least the supplied membership level for the Workroom. /// </summary> /// <param name="membershipLevel">The membership level to test.</param> /// <returns><c>true</c> if the user has sufficent membership level; otherwise <c>false</c>.</returns> public bool QueryDistinctMembershipLevel(MembershipLevels membershipLevel) { return(Membership.QueryDistinctMembershipLevel(CurrentPage, membershipLevel)); }