h2o
h2o

Reputation: 513

Disable "Advanced ..." in workflow status menu in Plone

I want to disable the "Advanced ..." (content_status_history) link in the workflow status menu for other roles except Managers and Site Administrators. Is there a permission that I can use to do this? Or is this link's permission coupled with the presence of a transition?

Upvotes: 2

Views: 255

Answers (2)

user2665694
user2665694

Reputation:

You should be able to hide the menu item by adding

a#advanced {
   display: none;
}

to your styles.

That's a pragmatic solution compared the bloated former clean solution.

Upvotes: 2

Martijn Pieters
Martijn Pieters

Reputation: 1123410

The link's presence is coupled to there being a workflow transition. The form it links to offers additional options to set for the transitions that are available on the current object. There is no permission that controls it's presence; the menu item is hardcoded.

From the plone.app.contentmenu.menu source:

    if len(results) > 0:
        results.append({ 'title'        : _(u'label_advanced', default=u'Advanced...'),
                         'description'  : '',
                         'action'       : url + '/content_status_history',
                         'selected'     : False,
                         'icon'         : None,
                         'extra'        : {'id': 'advanced', 'separator': 'actionSeparator', 'class': 'kssIgnore'},
                         'submenu'      : None,
                        })

To provide your own implementation (perhaps using a subclass that removes the last option again if certain conditions are met), you'd have to use an override to redefine the browser:menu registration.

In your overrides.zcml you'd have to point to your own implementation using the following browser:menu declaration:

  <browser:menu
    id="plone_contentmenu_workflow"
    title="The 'workflow' menu - allows the user to execute workflow transitions"
    class=".yourmodule.YourWorkflowMenu"
    />

then in yourmodule.py create a YourWorkflowMenu class, something like:

from plone.app.contentmenu.menu import WorkflowMenu

class YourWorkflowMenu(WorkflowMenu):
    def getMenuItems(self, context, request):
        results = super(YourWorkflowMenu, self).getMenuItems(context, request)
        if len(results) > 0 and someothercondition:
            # Remove status history menu item ('Advanced...')
            results = [r for r in results
                if not r['action'].endswith('/content_status_history')]
        return results

Upvotes: 3

Related Questions