0

I have a custom group with members in them and I would like that group to have access to the plugin.

In my init.rb :

  menu :application_menu, :release_approbation, {:controller => 'release_approbation', :action => 'index'}, :if => Proc.new { User.current.allowed_to?(:release_view, nil, :global => true) }, :caption => 'Release Approbation'
  permission :release_view, :release_approbation => :index, :require => :loggedin
  permission :release_approve, :release_approbation => :approve, :require => :loggedin

In my controller :

  before_filter :authorize_global, :release_approbation => :index
  before_filter :authorize_global, :release_approbation => :approve

In my redmine admin panel in roles and permission, the group I added have the permission to the plugin actions. This is not part of any project, but a global plugin.

Lorac
  • 395
  • 1
  • 4
  • 14

1 Answers1

0

Let's see. You can check if that permission is in a role with something like this :

<% if User.current.allowed_to?(:permission_name, nil, :global => true) %>

This will try to find the permission you require from the member_roles table. Since you added the permission to all the users of that group , this will do the trick.
To not render the link to the plugin you can do something like this inside init.rb (Taken from Timesheet plugin):

    menu(:top_menu,
     :timesheet,
     {:controller => :timesheet, :action => :index},
     :caption => :timesheet_title,
     :if => Proc.new {
       User.current.allowed_to?(:see_project_timesheets, nil, :global => true) ||
       User.current.allowed_to?(:view_time_entries, nil, :global => true) ||
       User.current.admin?
     })

Its checking if the current user have privileges as admin or has any of these permissions, :see_project_timesheets or :view_time_entries. I hope this help you.

Ruben Barbosa
  • 151
  • 1
  • 12