Plugin Support for extending the top menu is not enough

Added by Chaoqun Zou over 9 years ago

Maybe it's wrong, but I think that it is not easy to add plugin's menu to the top menu at now.

The point is the authorize method in redmine's ApplicationController.

It is very easy to add plugin's menu to the top menu using menu :top_menu,...

But when you have done this, you cann't use the authorize method of redmine to protect your plugin's action. The authorize method needs a project object to check the user's permission. So if the plugin is not attached to a project, the project object will always be nil which will causing the authorize method to return false every time.

It's not a good way that a plugin doesn't use redmine's authorize mechanism.

So I think that extending plugin to the top menu still needs more support, right?

Replies (2)

RE: Plugin Support for extending the top menu is not enough - Added by yanyu wang over 9 years ago

Try

menu : top_menu, :plugin_example, { :controller => 'example', :action => 'say_hello' }, :caption => 'Sample', :if => authorize_for('example', 'say_hello').

RE: Plugin Support for extending the top menu is not enough - Added by Chaoqun Zou over 9 years ago

Hi, yanyu.

I think the if option just hides the menu when he doesn't have permission. If he uses the full url to access the action, the protection will be bypassed. Is it correct?

(1-2/2)