public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { // get page of context var parent = context.Parent; while (!parent.IsPage) { if (parent.Parent == null) return AllowedDefinitionResult.Deny; parent = parent.Parent; } var parentType = parent.GetType(); if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType)) { if (Attribute.Types != null && !Attribute.Types.Any(t => t.IsAssignableFrom(parentType))) { //Trace.TraceInformation(context.ChildDefinition.ItemType.Name + " denied on " + parentType.Name); return AllowedDefinitionResult.Deny; } //if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey)) // return AllowedDefinitionResult.Deny; } return AllowedDefinitionResult.DontCare; }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { if (parentType.IsAssignableFrom(context.ParentDefinition.ItemType) && IsAssignable(context.ChildDefinition.ItemType)) return AllowedDefinitionResult.Allow; else return (option == IntegrityMappingOption.AddToExising) ? AllowedDefinitionResult.DontCare : AllowedDefinitionResult.Deny; }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { if (IsAssignable(context.ChildDefinition.ItemType)) if(TemplateNames == null || TemplateNames.Contains(context.ChildDefinition.TemplateKey)) return AllowedDefinitionResult.DontCare; return AllowedDefinitionResult.Deny; }
private static bool IsAllowed(ItemDefinition definition, ContentItem parentItem, ItemDefinition parentDefinition, IDefinitionManager definitions) { var ctx = new AllowedDefinitionQuery { Parent = parentItem, ParentDefinition = parentDefinition, ChildDefinition = definition, Definitions = definitions }; var filters = parentDefinition.AllowedChildFilters.Union(definition.AllowedParentFilters).ToList(); if (filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Allow)) return true; else if (!filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Deny)) return true; return false; }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType)) { if (this.Attribute.Types != null && !this.Attribute.Types.Any(t => t.IsAssignableFrom(context.ParentDefinition.ItemType))) return AllowedDefinitionResult.Deny; if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey)) return AllowedDefinitionResult.Deny; } return AllowedDefinitionResult.DontCare; }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery query) { if (query.ParentDefinition == null) return AllowedDefinitionResult.DontCare; if (query.Parent == null) return AllowedDefinitionResult.DontCare; var type = ComparableType ?? query.ChildDefinition.ItemType; int childrenOfTypeCount = query.Parent.Children.Count(i => type.IsAssignableFrom(i.GetContentType())); if (childrenOfTypeCount >= MaximumCount) return AllowedDefinitionResult.Deny; return AllowedDefinitionResult.DontCare; }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery query) { var isDragAndDrop = ControlPanel.GetState(N2.Context.Current).HasFlag(ControlPanelState.DragDrop); // dont show the plugin when drag and dropping (only for blogcontainer editing). if (isDragAndDrop) return AllowedDefinitionResult.Deny; // only allowed below blog container return !typeof(BlogContainer).IsAssignableFrom(query.ParentDefinition.ItemType) ? AllowedDefinitionResult.Deny : AllowedDefinitionResult.Allow; }
private static bool IsAllowed(ItemDefinition definition, ContentItem parentItem, ItemDefinition parentDefinition, IDefinitionManager definitions) { var ctx = new AllowedDefinitionQuery { Parent = parentItem, ParentDefinition = parentDefinition, ChildDefinition = definition, Definitions = definitions }; var filters = parentDefinition.AllowedChildFilters.Union(definition.AllowedParentFilters).ToList(); if (filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Allow)) { return(true); } else if (!filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Deny)) { return(true); } return(false); }
/// <summary>Gets or sets additional child types allowed below this item.</summary> public IEnumerable <ItemDefinition> GetAllowedChildren(IDefinitionManager definitions, ContentItem parentItem) { IEnumerable <ItemDefinition> all = definitions.GetDefinitions().ToList(); foreach (var d in all) { var ctx = new AllowedDefinitionQuery { Parent = parentItem, ParentDefinition = this, ChildDefinition = d, Definitions = definitions }; var filters = AllowedChildFilters.Union(d.AllowedParentFilters).ToList(); if (filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Allow)) { yield return(d); } else if (!filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Deny)) { yield return(d); } } }
private static bool IsAllowed(ContentItem childItem, ItemDefinition childDefinition, ContentItem parentItem, ItemDefinition parentDefinition, IDefinitionManager definitions) { var ctx = new AllowedDefinitionQuery { Parent = parentItem, ParentDefinition = parentDefinition, Child = childItem, ChildDefinition = childDefinition, Definitions = definitions }; var filters = parentDefinition.AllowedChildFilters.Union(childDefinition.AllowedParentFilters).ToList(); if (filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Allow)) { // filter specificly allows -> allow return(true); } else if (!filters.Any(f => f.IsAllowed(ctx) == AllowedDefinitionResult.Deny)) { // no filter denies -> allow return(true); } // no filter allowed, but some filter denied -> deny return(false); }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { return IsAssignable(context.ChildDefinition.ItemType) ? AllowedDefinitionResult.Allow : AllowedDefinitionResult.DontCare; }