Copied to clipboard

Flag this post as spam?

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


  • Wesley Herpoelaert 52 posts 123 karma points
    Jul 12, 2010 @ 13:43
    Wesley Herpoelaert
    0

    User permissions on Document Types

    Hello,

    Can I set user permissions on Document Types?

    Thanks in advance

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Jul 12, 2010 @ 13:57
    Tim
    0

    Do you mean permissions to add/edit document types, or permissions for users who are adding/editing content with the document types?

  • Wesley Herpoelaert 52 posts 123 karma points
    Jul 12, 2010 @ 14:13
    Wesley Herpoelaert
    0

    Sorry, I mean permissions for users who are adding/editing content with the document types.
    e.g. Is it possible to define which user may create content with a particular Document Type?

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Jul 12, 2010 @ 15:11
    Tim
    0

    I don't think that's possible out of the box.

    You can limit what content can be added in a section by document type (so for example under news archive you can limit users to only adding news articles). You can also limit users as to which sections they can add content into, using the permissions section in their user details. But the permissions aren't tied into the document types, you can either add all allowable content types under a document, or none.

    It might be possible to write something that would allow you to do this, but I'd imagine that it'd be quite a big task.

  • LeeAnn Feiertag 4 posts 24 karma points
    Sep 15, 2011 @ 22:17
    LeeAnn Feiertag
    0

    We are using Umbraco v4.6.1 and I have been requested to limit some users to a specific document type.  Can I do this in v 4.6.1?  If not, will I be able to limit users to a specific doc type in 4.7?  We are moving to v 4.7 soon.

    Thanx!

  • Damian Green 452 posts 1433 karma points
    Nov 15, 2012 @ 14:06
    Damian Green
    0

    I know this post is a little old but I was just looking into this myself and have had the idea of using the context menus and events to manage this feature.

    You could maintain a lits of doc types you want to protect by role and manage the context menu to remove the create/delete/sort/move etc based on this.

    That should work shouldnt it?

    Article on it here:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/event-examples/remove-context-menu-items

     

  • Damian Green 452 posts 1433 karma points
    Nov 15, 2012 @ 14:10
    Damian Green
    0

    Actually I now see a flaw thinking about it.  It would work for items when you are on one of the doc types in question or has a parent of that type but not say at the top level of your site.  I guess you would just have to remove this from the list of available doctypes in this situation.

    It would be nice to be able to either get at the create dialogue or set security on the doc types.  

    Am i right in saying this was going to be a feature of v5?

     

  • Damian Green 452 posts 1433 karma points
    Nov 15, 2012 @ 14:56
    Damian Green
    0

    Ok ive sussed a way of doing it.  Not perfect and you would need to ensure that the functionality doesnt get zapped when you do an upgrade but heres a little hack:

    Find out the UI control you need to edit using umbraco/config/create/UI.xml - in this instance its the /umbraco/create/content.ascx

    Open up the user control and place method listed below at the top after the page declarations.  You may need to change the test condition to a specific group but its a nice quick way to get something you need without tons of work.

    A better way would be to create another user control and edit the UI.xml file to point to the new control - that way your control code wouldnt get overwritten by an umbraco update.

    Maybe someone else has an even better way?

     

    <script language="c#" runat="server">
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

       

        if (!umbraco.BusinessLogic.User.GetCurrent().IsAdmin())
        {
        ListItem i = nodeType.Items.FindByText("YourDocType");
        if (i != null)
        {
          nodeType.Items.Remove(i);
        }
        }
    }
    </script>
  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Nov 15, 2012 @ 15:11
    Tim
    1

    Hiya,

    I actually wrote a package that does this that allows you to modify the menus for content of specific DocTypes AND specific node ids, and allows you to vary the rules by user as well.

    http://our.umbraco.org/projects/backoffice-extensions/attackmonkey-custom-menus

    :)

  • Matt 76 posts 280 karma points
    Mar 14, 2013 @ 03:00
    Matt
    0

    i used the above concept and ended up with the code below in cotnent.ascx - if i want to disallow a doctype from being created by a non-admin I just put disallow in the doctype description - admins are smart enough to ignore the description text when creating the items.  I'm using uSiteBuilder so I just add it in there if its something like settings or a "collection type node" like "News" that I dont want end users creating (I create it once for them).

    <script language="c#" runat="server">
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //get the document type names into cache that are disallowed for non admins
            HttpContext context = HttpContext.Current;
            List<string> disAllowedDocNames = (context.Cache["disAllowedDocNames"] == null ? null : (context.Cache["disAllowedDocNames"] as List<string>));
            if (disAllowedDocNames == null)
            {
                disAllowedDocNames = new List<string> { };
                List<umbraco.cms.businesslogic.web.DocumentType> docTypes = umbraco.cms.businesslogic.web.DocumentType.GetAllAsList();
                foreach (umbraco.cms.businesslogic.web.DocumentType dt in docTypes.Where(dti => dti.Description.ToLower().Contains("disallow")))
                    disAllowedDocNames.Add(dt.Text);
                context.Cache.Insert("disAllowedDocNames", disAllowedDocNames);
            }

            if (!umbraco.BusinessLogic.User.GetCurrent().IsAdmin()) 
            {
                foreach (ListItem li in nodeType.Items)
                {
                    if (disAllowedDocNames.Contains(li.Text))
                        li.Enabled = false;
                }
            }
        }
    </script>

    hope this helps someone else out

  • Tony Groome 261 posts 804 karma points
    Jul 23, 2015 @ 15:34
    Tony Groome
    0

    I did a workaround here

    workaround

    This blocked the content editor from higher level content so they can only access what I want them to! Hope that helps - some years later! :)

    Tony

  • Ashford Borough Council Dev Team 25 posts 158 karma points
    Aug 18, 2015 @ 14:23
    Ashford Borough Council Dev Team
    0

    We had the same requirement to be able to disallow certain user types from creating specific document types. After a lot of digging and trial and error we have come up with a solution. The only downside is that it relies on hard coding of user types and doc type aliases, but as our system is now fairly well established these are not likely to change much in the future.

    The workaround is in two parts. The first is to add a filter to the ng-repeat in the view where the available document types are listed (Umbraco/Views/content/create.html) as follows;

    <li ng-repeat="docType in allowedTypes | filter:filteredDocTypes | orderBy:'name':false">
    

    Next is to add the filteredDocTypes function to the contentCreateController function (Umbraco/Js/umbraco.contollers.js) to filter out disallowed doc types based on user type. Without going into too much more explanation, here is the updated contentCreateController function snippet;

    function contentCreateController($scope, $routeParams, contentTypeResource, iconHelper, userService) {
    
        userService.getCurrentUser().then(function (user) {
            $scope.currentUserType = user.userType;
        });
    
        contentTypeResource.getAllowedTypes($scope.currentNode.id).then(function(data) {
            $scope.allowedTypes = iconHelper.formatContentTypeIcons(data);
        });
    
        $scope.filteredDocTypes = function(docType){
    
            if ($scope.currentUserType === 'writer') {
                    return docType.alias != 'ECCalendar' && docType.alias != 'NewsLandingPage';
                }
            else {
                    return docType.alias != '';
            }
    
        };
    
    }
    

    In the example, users of type 'writer' will not have the option to create content of doc types ECCalendar or NewsLandingPage. It's only had a minimal amount of testing but it appears to give the desired result.

  • Amir 75 posts 224 karma points
    Nov 03, 2015 @ 11:54
    Amir
    0

    This article will show you the best way to hide a document-type from create menu items.

Please Sign in or register to post replies

Write your reply to:

Draft