Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Image Gallery Delete for Non-Admins


Reply


8 Posts   1194 Views

Avatar
Andrew Houle

Community Member, 133 Posts

4 May 2010 at 1:29am

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

4 May 2010 at 4:04am

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.?

Avatar
Andrew Houle

Community Member, 133 Posts

4 May 2010 at 7:11am

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?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

4 May 2010 at 7:38am

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

ImageGalleryItem::$delete_permission = "CMS_ACCESS_CMSMain";

to your _config.php.

Avatar
Andrew Houle

Community Member, 133 Posts

4 May 2010 at 8:07am

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

Avatar
jak

Community Member, 46 Posts

4 June 2010 at 10:49pm

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

5 June 2010 at 2:18am

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?

Avatar
jak

Community Member, 46 Posts

5 June 2010 at 3:27am

Edited: 05/06/2010 3:31am

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.