Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jacky joy 2 posts 72 karma points
    May 08, 2021 @ 12:31
    jacky joy
    0

    The Umbraco document type permissions ?.

    Hello,

    Is there a way to limit certain users/user groups from creating particular document types? Has any of you done this and if yes - how? https://krogerfeedback.nl https://talktosonic.onl https://talktowendys.vip https://whataburgersurvey.onl

    thanks jackyjoy

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    May 09, 2021 @ 10:06
    Marc Goodson
    2

    Hi Jacky Joy

    There isn't a perfect answer here but:

    Usually this functionality is useful if you have a Document Type you want to create 'once' in the content tree, eg News Section and not have editors create multiple News Sections...

    ... if that's your use case here then what most people will do, after creating them once, is to remove the ability to create them from the structure permissions of the DocType under which they are allowed to be created (or root of site for top level folders). It doesn't cause any problems with content that has existingly been created, but prevents people 'copying' or 'creating' new nodes of that type in the future.

    If an Admin did need to create one for 'some reason' they could always tick the box to allow it to be created, create it, and then untick the box again!

    But if your needs are more nunanced then - the other tricks you have available is the handling of static events:

    ContentService.Saving - which would allow you to check before a content item is saved, whether the person saving, it should be allowed to save it, in the context it is in, and you can 'cancel the save' and show a notification message.

    https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events

    Similarly there are deleting, and moving events that would allow you to stop other CRUD operations in their tracks.

    There is also another more obscure event.. EditorModelManager - SendingContentModel, which is fired 'just before' the UI is shown to allow an editor to edit or create a page:

    https://our.umbraco.com/Documentation/Reference/Events/EditorModel-Events/

    So again you could check User Groups here, and modify what can be edited, eg make fields 'read only' etc before people have created content...

    What you are talking to is the subject of a couple of other PRs into the core - which haven't been concluded:

    https://github.com/umbraco/Umbraco-CMS/pull/9595 and https://github.com/umbraco/Umbraco-CMS/pull/9906

    These focus around 'creating more events' that would allow us implementors to control what appears on that 'create menu' - so people in the wrong User Group would not even get the chance to create content and other people in the privileged groups would... which I think is what you are after...

    In the short term, the other way of customising Umbraco would be to hijack the webapi request that is being made to retrieve the options to display to the user, on the create menu and manipulate these options before the api returns to the UI.

    In that second PR, there is a comment from Shannon

    https://github.com/umbraco/Umbraco-CMS/pull/9906#issuecomment-787547487

    which says:

    Side note - it would be possible to add a webapi global filter to your application on startup and handle it that way. You could then handle any response's object model and tweak it if you wanted. This would be more flexible in the long run instead of adding a new event for every web api response.

    So adding a global filter for all Web Api requests, would seem like one way to do this ( have never done it myself)

    The other approach (which have used before) would be to hijack the api request in angularJS, there is a great article here from Soren Kottal that explains how to do this to provide a different 'search implementation' for the ListView - the same principle could be used to manipulate the create options based on User Groups for the api request that populates the Create menu

    https://dev.to/skttl/how-to-customize-searching-in-umbraco-list-views-1knk

    Anyway sorry to waffle on and not answer the question, hope that helps in someway!

    regards

    marc

Please Sign in or register to post replies

Write your reply to:

Draft