diff --git a/CHANGES.rst b/CHANGES.rst index 73e4f0b4..fbd0165f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,9 @@ Changelog New: -- *add item here* +- Add option to show/hide thumbs in site-controlpanel + https://github.com/plone/Products.CMFPlone/issues/1241 + [fgrcon] Fixes: diff --git a/plone/app/layout/globals/layout.py b/plone/app/layout/globals/layout.py index 0e6d5673..a28dceab 100644 --- a/plone/app/layout/globals/layout.py +++ b/plone/app/layout/globals/layout.py @@ -98,6 +98,24 @@ def icons_visible(self): else: return False + @memoize + def thumb_visible(self): + """Returns True if thumbs should be shown or False otherwise. + """ + context = self.context + membership = getToolByName(context, "portal_membership") + anon = membership.isAnonymousUser() + registry = getUtility(IRegistry) + settings = registry.forInterface(ISiteSchema, prefix="plone", check=False) + thumb_visibility = settings.thumb_visibility + + if thumb_visibility == 'enabled': + return True + elif thumb_visibility == 'authenticated' and not anon: + return True + else: + return False + def getIcon(self, item): """Returns an object which implements the IContentIcon interface and provides the informations necessary to render an icon. The item @@ -179,6 +197,12 @@ def bodyClass(self, template, view): else: body_classes.append('icons-off') + # class for hiding thumbs (optional) + if self.thumb_visible(): + body_classes.append('thumbs-on') + else: + body_classes.append('thumbs-off') + # permissions required. Useful to theme frontend and backend # differently permissions = []