public IEnumerable<ContentType> GetAllowedChildTypes()
{
// in case of folders and pages inherit settings from parent
if (this.NodeType.Name == "Folder" || this.NodeType.Name == "Page")
{
var parent = Parent as GenericContent;
if (parent == null)
return ContentType.EmptyAllowedChildTypes;
return parent.GetAllowedChildTypes();
}
// collect types set on local instance
var types = new List<ContentType>();
var hasLocalItems = false;
foreach (var ct in this.AllowedChildTypes)
{
hasLocalItems = true; //-- Indicates that the local list has items. The length of list is not enough because the permission filters the list and if the filter skips all elements, the user gets the list that declared on the content type.
if (ct.Security.HasPermission(PermissionType.See))
types.Add(ct);
}
// SystemFolder and TrashBag allows every type if there is no setting on local instance
var systemFolderName = "SystemFolder";
if (!hasLocalItems && (this.NodeType.Name == systemFolderName || this.NodeType.Name == "TrashBag"))
return new ContentType[0];
// SystemFolder can be created anywhere if the user has the necessary permissions on the CTD
var systemFolderType = ContentType.GetByName(systemFolderName);
if (systemFolderType.Security.HasPermission(PermissionType.See))
if (!types.Contains(systemFolderType))
types.Add(systemFolderType);
if (hasLocalItems)
return types;
// settings come from CTD if no local setting is present
foreach (var ct in this.ContentType.AllowedChildTypes)
{
if (ct.Security.HasPermission(PermissionType.See))
if (!types.Contains(ct))
types.Add(ct);
}
return types;
}
public bool IsAllowedChildType(string contentTypeName)