Пример #1
0
 public IEnumerable <ContentTypeDefinition> GetTerritoryTypes()
 {
     return(_contentDefinitionManager.ListTypeDefinitions()
            .Where(ctd => ctd.Parts.Any(pa => pa
                                        .PartDefinition.Name.Equals(TerritoryPart.PartName, StringComparison.InvariantCultureIgnoreCase)) &&
                   _authorizer.Authorize(TerritoriesPermissions.GetTerritoryPermission(ctd))));
 }
 public void Adjust(CheckAccessContext context)
 {
     if (!context.Granted &&
         context.Content.Is <TerritoryPart>())
     {
         var typeDefinition = context.Content.ContentItem.TypeDefinition;
         //replace permission if there is one specific for the content type
         if (typeDefinition.Parts.Any(ctpd => ctpd.PartDefinition.Name == TerritoryPart.PartName) &&
             context.Permission == TerritoriesPermissions.ManageTerritories)
         {
             context.Adjusted   = true;
             context.Permission = TerritoriesPermissions.GetTerritoryPermission(typeDefinition);
         }
     }
 }