/// <summary>
        /// Fill the treeview with all albums. All nodes representing albums for which the specified role has permission
        /// will be checked. If the overload that doesn't take a role parameter is used, then check all checkboxes if the
        /// isAdministratorChecked parameter is true.
        /// </summary>
        /// <param name="role">The role to be updated. If adding a new role, then set this parameter to null.</param>
        /// <param name="isAdministrator">Indicates whether the administrator permission checkbox has been
        /// checked or the specified role has administrative permission. Since administrative permission applies to all
        /// albums, when this parameter is true, all checkboxes for all albums will be checked. An exception is thrown
        /// if the role.AllowAdministerSite property and the isAdministrator parameter do not match.</param>
        private void BindAlbumTreeview(IGalleryServerRole role, bool isAdministrator)
        {
            if ((role != null) && (role.AllowAdministerSite != isAdministrator))
            {
                throw new ArgumentException("Invalid arguments passed to BindAlbumTreeview method: The role.AllowAdministerSite property and the isAdministrator parameter must match.");
            }

            if (role != null)             // Role will be null when user is adding a new role
            {
                IIntegerCollection albumIds = tvUC.AlbumIdsToCheck;
                albumIds.Clear();
                albumIds.AddRange(role.RootAlbumIds);

                foreach (IGallery gallery in Factory.LoadGalleries())
                {
                    IAlbum rootAlbum = Factory.LoadRootAlbumInstance(gallery.GalleryId);

                    if (role.RootAlbumIds.Contains(rootAlbum.Id))
                    {
                        // The role applies to all albums. Since the treeview initially renders to two levels, we need
                        // to add the album IDs for the root album's child albums.
                        foreach (IGalleryObject album in rootAlbum.GetChildGalleryObjects(GalleryObjectType.Album))
                        {
                            albumIds.Add(album.Id);
                        }
                    }
                }
            }

            tvUC.RequiredSecurityPermissions = SecurityActions.AdministerSite | SecurityActions.AdministerGallery;
            tvUC.Galleries       = Factory.LoadGalleries();
            tvUC.RootAlbumPrefix = String.Concat(Resources.GalleryServerPro.Site_Gallery_Text, " '{GalleryDescription}': ");
            tvUC.BindTreeView();
        }
Beispiel #2
0
        /// <summary>
        /// Fill the treeview with all albums. All nodes representing albums for which the specified role has permission
        /// will be checked. If the overload that doesn't take a role parameter is used, then check all checkboxes if the
        /// isAdministratorChecked parameter is true.
        /// </summary>
        /// <param name="role">The role to be updated. If adding a new role, then set this parameter to null.</param>
        /// <param name="isAdministrator">Indicates whether the administrator permission checkbox has been
        /// checked or the specified role has administrative permission. Since administrative permission applies to all
        /// albums, when this parameter is true, all checkboxes for all albums will be checked. An exception is thrown
        /// if the role.AllowAdministerSite property and the isAdministrator parameter do not match.</param>
        private void BindAlbumTreeview(IGalleryServerRole role, bool isAdministrator)
        {
            if ((role != null) && (role.AllowAdministerSite != isAdministrator))
            {
                throw new ArgumentException("Invalid arguments passed to BindAlbumTreeview method: The role.AllowAdministerSite property and the isAdministrator parameter must match.");
            }

            if (role != null)             // Role will be null when user is adding a new role
            {
                IIntegerCollection albumIds = tvUC.AlbumIdsToSelect;
                albumIds.Clear();
                albumIds.AddRange(role.RootAlbumIds);

                if (role.RootAlbumIds.Contains(Factory.LoadRootAlbumInstance().Id))
                {
                    // The role applies to all albums. Since the treeview initially renders to two levels, we need
                    // to add the album IDs for the root album's child albums.
                    foreach (IGalleryObject album in Factory.LoadRootAlbumInstance().GetChildGalleryObjects(GalleryObjectType.Album))
                    {
                        albumIds.Add(album.Id);
                    }
                }
            }

            tvUC.BindTreeView();
        }