Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Image Gallery Delete for Non-Admins

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1081 Views
  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Image Gallery Delete for Non-Admins Link to this post

    Is it possible in the image gallery module to allow non administrators the ability to delete the images in the Photos tab? The icon doesn't appear for them when you roll over an image.

    Thanks in advance,
    Andrew

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    Well, that's cute. Looks like 2.4 sets all the canXXX() functions to default to ADMIN perms in DataObject.php. Not sure how to handle this one. Maybe have a static class property in ImageGalleryItem for $delete_permission, $edit_permission, etc.?

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    Ha, that is cute! I don't want to hack the core of the module. I wonder if there is a simple way to override that default behavior?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    Using the latest rev, you should be able to add something like:

    ImageGalleryItem::$delete_permission = "CMS_ACCESS_CMSMain";

    to your _config.php.

  • Andrew Houle
    Avatar
    Community Member
    132 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    I just made this change, it works perfect, thanks!

  • jak
    Avatar
    Community Member
    46 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    Could you change the default value of this property in ImageGalleryItem.php to this more "liberal" value?
    I.e. public static $delete_permission = 'CMS_ACCESS_CMSMain';

    I think there are a lot of users who will stumble upon this. It is very strange to set this to ADMIN since it is only a "cosmetic" property - it just hides the delete link (trashcan icon). If you know the ID of the item you still can delete it using the direct link http://yoursite/admin/EditForm/field/GalleryItems/item/ITEM_ID/delete

    Jak

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    That was a really weird quirk in 2.4. By default, you couldn't delete ImageGalleryItems, so I had to add a canDelete() function to them. I wasn't happy with that addition either, but don't you think CMSMain is an appropriate level of permissions for deleting from the image gallery?

  • jak
    Avatar
    Community Member
    46 Posts

    Re: Image Gallery Delete for Non-Admins Link to this post

    In my opinion the apropriate permission would be the one needed to delete the file and the Database Entry (i.e. the ImageGalleryItem). With CMS_ACCESS_CMSMain you are able to do this.
    In the version currently in the SVN ADMIN is needed, which in my opinion is to high.

    1081 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.