Orchard: Filter out Content Types From Restricted Users.

I want to be very clear I did not write this code but it was provided to me and I was given permission by a colleague of mine to submit it.. To respect his privacy I will not be able to provide his name but on his behalf I did submit the code to help improve the orchard project. To explain it a little bit what the purpose of this code edit, it is to filter out content that is editable but the user does not have the permissions to create them. Normal what Orchard would do is display all creatable content and if a user clicks on a particular content type that is restricted it simply replies to the user that they do not have access to it. However with a lot of CMS projects I have developed it is sometimes better to simply hide what the user can not or should not be able to do. Less questions come up and even less problems are seen from the user's perspective. This is what I consider to be a best practice to provide the user with a good experience.

The Location:\orchard\src\Orchard.Web\Core\Contents\Controllers\AdminController.cs

private IEnumerable<ContentTypeDefinitionGetCreatableTypes(bool andContainable) {
            return _contentDefinitionManager.ListTypeDefinitions().Where(ctd =>
                Services.Authorizer.Authorize(Permissions.EditContent, _contentManager.New(ctd.Name)) &&
                ctd.Settings.GetModel<ContentTypeSettings>().Creatable &&
                (!andContainable || ctd.Parts.Any(p => p.PartDefinition.Name == "ContainablePart")));

Contributing patches - Orchard Documentation

CodePlex Information and Discussion - Home

Git Commands - Just cause I was having a little trouble making the commit.
git clone https://git-repository FolderName
git commit -am "some msg!" - Did 'a' just cause I was inside the clone folder
git push --all -Again just used all because it was the only project and I was inside the clone folder.


Popular posts from this blog

Nginx Best Practices Extended

Installing Windows on Acer chromebook 15 cb3-532

Entity Framework: ToListAynsc & WhereAsync