Esempio n. 1
0
        private void ApplyPermissions(File folder, string view)
        {
            if (!UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
            {
                lnkViewTrashOrFilesImage.Visible = false;
                lnkViewTrashOrFiles.Visible = false;
            }

            if (view == "trash")
            {
                //trash view
                HideAddNewMenu();
                radMenuBreadCrumbs.Visible = false;
                return;
            }

            //site root folder, hide all actions
            if (folder == null)
            {
                //leave actions for admin user
                if (!UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    HideAddNewMenu();
                }
                else
                {
                    ShowMessage("This is the root folder for the site.  Only site administrators can add items to this folder.", ModuleId);
                }
                return;
            }

            if (!folder.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                radLVFiles.Visible = false;
                radMenuBreadCrumbs.Visible = false;
                radMenuNewItems.Visible = false;
                ShowUserErrorMessage("You are not permitted to view items at this location.", ModuleId);
            }

            if (!folder.CanAddFile(UserId, PortalId, PortalSettings.AdministratorRoleId, false))
            {
                HideAddNewItems();
            }

            if (!folder.CanAddFolder(UserId, PortalId, PortalSettings.AdministratorRoleId, false))
            {
                HideAddNewFolder();
            }
        }
        private void ApplyPermissions(File file)
        {
            string strMyPermission = "";

            //check if in trash, lock down changes
            if (file.IsInTrash)
            {
                //disable edit controls
                txtDescription.Enabled = false;
                txtName.Enabled = false;
                txtVersionsToKeep.Enabled = false;
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                lbnOK.Visible = false;

                //disable permission controls
                lbnAddUser.Visible = false;
                txtUser.Visible = false;
                lblUser.Visible = false;
                gridPermissions.Enabled = false;
            }

            //see
            if (!file.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                Response.Redirect(Globals.NavigateURL());
            }
            else
            {
                strMyPermission = "See, ";
            }

            //add items
            if (file.CanAddFile(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                strMyPermission = strMyPermission + "Add Items, ";
            }

            //add folders
            if (file.CanAddFolder(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                strMyPermission = strMyPermission + "Add Folders, ";
            }

            //modify
            if (!file.CanModify(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                //disable edit controls
                txtDescription.Enabled = false;
                txtName.Enabled = false;
                txtVersionsToKeep.Enabled = false;
                txtHyperlink.Enabled = false;
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                lbnOK.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Modify, ";
            }

            //delete
            if (!file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                this.linkDelete.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Delete, ";
            }

            //edit permission
            if (!file.CanEditPermissions(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                gridPermissions.Visible = false;
                txtUser.Visible = false;
                lblPermissionsGrid.Visible = false;
                lblUser.Visible = false;
                lbnAddUser.Visible = false;
                ApplyPermissionToSubItems.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Edit Permissions, ";
                if (file.ItemType != 0)
                {
                    ApplyPermissionToSubItems.Visible = false;
                }
            }

            lblMyPermissions.Text = strMyPermission.Substring(0, strMyPermission.Length - 2);

            //remove versions for folder and hyperlink regardless
            if (file.ItemType == 0 || file.ItemType == 2)
            {
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                txtVersionsToKeep.Visible = false;
                lblVersionCount.Visible = false;
                liVersions.Visible = false;
                lblVersionToKeepLabel.Visible = false;
                lblVersionCountLabel.Visible = false;
                gridVersions.Visible = false;
            }
        }