Results 1 to 5 of 5

Thread: Keep Users from Deleting Content

  1. #1
    User
    Join Date
    10-15-10.
    Posts
    279

    Default Keep Users from Deleting Content

    I can keep users from deleting articles, but I can't find a way to keep them from deleting content in the articles. Is there a way to be this granular with User Settings?

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Keep Users from Deleting Content

    I don't know how to make this granular to the point that you are checking user and group permissions -- you'll probably have to reverse engineer something. But a quick and dirty way is to disable it for non-admins.

    Code:
    // You can put this in dcaconfig
    if( !$this->User->isAdmin )
    {
    	// Non-admins can't copy
    	unset( $GLOBALS['TL_DCA']['tl_content']['list']['operations']['copy'] );
    
    	// Non-admins can't cut
    	unset( $GLOBALS['TL_DCA']['tl_content']['list']['operations']['cut'] );
    
    	// Non-admins can't delete
    	unset( $GLOBALS['TL_DCA']['tl_content']['list']['operations']['delete'] );
    
    	// Hides that Info icon for non-admins
    	unset( $GLOBALS['TL_DCA']['tl_content']['list']['operations']['show'] );
    
    	// Don't let non-admins create new content elements
    	$GLOBALS['TL_DCA']['tl_content']['config']['closed'] = true;
    }
    Brian

  3. #3
    User
    Join Date
    10-15-10.
    Posts
    279

    Default Re: Keep Users from Deleting Content

    Thanks for that bit o' code.

    I'll have to see what the boss wants done for this. We have Writers, Editors, Publishers, and Admins... as far as I know, both Publishers and Admins will have rights to delete content, but others will not. Not sure if she will want to give Publishers admin rights however.

    Maybe I can make an alternate backend template for these user groups to utilize and just remove instances of those buttons from the template?

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Keep Users from Deleting Content

    Possibly -- but I'm not sure you could do that through a template, since everything is so dynamic.

    A better strategy might be to check out, say, the news module and see how it checks for permissions. You just need to replace my "if" statement with whatever checks are necessary for user groups. It might be surprisingly straightforward.

    It's something I have on my list of things to learn, but haven't gotten to it yet.
    Brian

  5. #5
    User
    Join Date
    10-15-10.
    Posts
    279

    Default Re: Keep Users from Deleting Content

    ...Edit...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •