/// <summary> /// Determines whether the currently logged on user has edit permissions on the specific item. /// </summary> /// <param name="item">The item.</param> /// <returns> /// <c>true</c> if the currently logged on user has edit permissions on the specific item; otherwise, <c>false</c>. /// </returns> public static bool CanEdit(VirtualFileBase item) { if (item == null) { return(false); } UnifiedDirectory dir = item as UnifiedDirectory; if (dir != null) { return(PrincipalInfo.HasAdminAccess || dir.QueryDistinctAccess(AccessLevel.Edit)); } UnifiedFile file = item as UnifiedFile; if (file != null && (PrincipalInfo.HasAdminAccess || file.QueryDistinctAccess(AccessLevel.Edit))) { IVersioningFile versioningFile = file as IVersioningFile; return(versioningFile == null || !IsCheckedOutBySomeoneElse(versioningFile)); } else { return(false); } }
/// <summary> /// Changes the enabled state of buttons based on current file manager state. /// </summary> private void EnableButtons() { Details.Enabled = IsDetailsAllowed(); Version.Enabled = IsVersionAllowed(); UnifiedDirectory currentDirectory = FileManager.CurrentVirtualDirectory; if (currentDirectory != null && currentDirectory.QueryDistinctAccess(AccessLevel.Create | AccessLevel.Edit | AccessLevel.Delete)) { DisabledFunctionsMessage.Visible = false; AddFile.Enabled = IsDefaultView(); AddFolder.Enabled = IsDefaultView(); Rename.Enabled = IsRenameAllowed(); Delete.Enabled = IsChangeAllowed(); Cut.Enabled = IsChangeAllowed(); Copy.Enabled = IsDefaultView() && FileManager.SelectedItems.Count > 0; Paste.Enabled = IsDefaultView() && FileManager.PasteBuffer.Count > 0; Checkout.Enabled = IsCheckOutAllowed(); UndoCheckout.Enabled = IsUndoCheckOutAllowed(); CheckIn.Enabled = IsCheckInAllowed(); } else { DisabledFunctionsMessage.Visible = true; AddFile.Enabled = false; AddFolder.Enabled = false; Rename.Enabled = false; Delete.Enabled = false; Cut.Enabled = false; Copy.Enabled = false; Paste.Enabled = false; Checkout.Enabled = false; UndoCheckout.Enabled = false; CheckIn.Enabled = false; } ApplyDisabledCssClassToDisabledButtons(); }