Changeset 16202 for trunk/HeuristicLab.Clients.Hive/3.3
- Timestamp:
- 10/01/18 15:14:44 (6 years ago)
- Location:
- trunk/HeuristicLab.Clients.Hive/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs
r16117 r16202 26 26 using System.Collections.Generic; 27 27 using System.Linq; 28 using HeuristicLab.Clients.Access; 28 29 29 30 namespace HeuristicLab.Clients.Hive { … … 438 439 } 439 440 441 public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) { 442 var missingParentIds = availableResources 443 .Where(x => x.ParentResourceId.HasValue) 444 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 445 .Where(x => !availableResources.Select(y => y.Id).Contains(x)); 446 447 return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id)); 448 } 449 440 450 public bool CheckAccessToAdminAreaGranted() { 441 451 if(projects != null) { … … 478 488 479 489 if(projectAncestors.ContainsKey(pro.Id)) { 480 return GetAvailableProjectAncestors(pro.Id).Where(x => x.OwnerUserId == userId).Any(); 490 return GetAvailableProjectAncestors(pro.Id).Any(x => x.OwnerUserId == userId); 491 } 492 493 if (pro.ParentProjectId != null && pro.ParentProjectId != Guid.Empty) { 494 var parent = projects.FirstOrDefault(x => x.Id == pro.ParentProjectId.Value); 495 if (parent != null) 496 return parent.OwnerUserId == userId || GetAvailableProjectAncestors(parent.Id).Any(x => x.OwnerUserId == userId); 481 497 } 482 498 … … 491 507 // ... or the new parent is not stored yet 492 508 // ... or there is not parental change 493 if (child == null 494 || (parent != null && parent.Id == Guid.Empty) 495 || (parent != null && parent.Id == child.ParentProjectId)) { 509 if (child == null 510 || (parent != null && parent.Id == Guid.Empty) 511 || (parent != null && parent.Id == child.ParentProjectId)) { 512 changePossible = false; 513 } else if (parent == null && !IsAdmin()) { 514 // ... if parent is null, but user is no admin (only admins are allowed to create root projects) 515 changePossible = false; 516 } else if (parent != null && (!IsAdmin() && parent.OwnerUserId != UserInformation.Instance.User.Id && !CheckOwnershipOfParentProject(parent, UserInformation.Instance.User.Id))) { 517 // ... if the user is no admin nor owner of the new parent or grand..grandparents 496 518 changePossible = false; 497 519 } else if(parent != null && projectDescendants.ContainsKey(child.Id)) { … … 525 547 return changePossible; 526 548 } 549 550 private bool IsAdmin() { 551 return HiveRoles.CheckAdminUserPermissions(); 552 } 527 553 #endregion 528 554 } -
trunk/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r16117 r16202 324 324 return resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id)); 325 325 } 326 327 public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) { 328 var missingParentIds = availableResources 329 .Where(x => x.ParentResourceId.HasValue) 330 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 331 .Where(x => !availableResources.Select(y => y.Id).Contains(x)); 332 333 return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id)); 334 } 326 335 #endregion 327 336
Note: See TracChangeset
for help on using the changeset viewer.