1

I am developing a redmine Plugin which has the task to offer some additional allow/disallow options, one of the features should be that the admin can allow/disallow the access to issue reports for everly role.

The Problem is that even if you try to redefine the permissions defined in redmine.rb in your plugins init.rb the permissions are merged, this leads to the fact that there is another permission (included in :view_issues) that allows access to issue reports.

How can I Override the permission defined in redmine.rb using my Plugins init.rb

My Plugins init.rb:

Redmine::Plugin.register :report_roles do
  name 'Report Roles plugin'
  author 'Author name'
  description 'This is a plugin for Redmine'
  version '0.0.1'
  url 'http://example.com/path/to/plugin'
  author_url 'http://example.com/about'

  Redmine::AccessControl.map do |map|
      map.project_module :issue_tracking do |map|
        map.permission :generate_issue_reports, {:reports => [:issue_report,:issue_report_details ]},:read => true
    end
  end    
end

And the relevant parts of my redmine.rb:

...

map.project_module :issue_tracking do |map|
    # Issue categories
    map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member
    # Issues
    map.permission :view_issues, {:issues => [:index, :show],
                                  :auto_complete => [:issues],
                                  :context_menus => [:issues],
                                  :versions => [:index, :show, :status_by],
                                  :journals => [:index, :diff],
                                  :queries => :index,
                                  :reports => [:issue_report, :issue_report_details]},
                                  :read => true
end

...

:reports => [:issue_report, :issue_report_details](included in :view_issues) also allows access to issue reports, I just want to "remove" the permission from :issue_viewsand make them an extra permission, because the :view_issues permission should be left enabled!

I also tried to redefine :view_issues in my init.rb, but that had no effect.

kevdev
  • 1,054
  • 8
  • 9
  • Additional: I dont want to modify the original sources, because it's too hard to maintain after every update. – kevdev Jul 31 '14 at 20:17
  • (If I understand you correctly) I don't like idea to **override** permissions, because your plugin will lost compatibility with other plugins which define own permissions and which are loaded before your plugin. I mean: given Redmine, plugin_1, plugin_2 (yours). Workflow is following: Redmine is loaded, Plugin_1 is loaded (a new permissions are added), Plugin_2 is loaded (override previous permissions). As a result permissions from Plugin_1 are lost. I would suggest you to find a way to merge it correctly and override one or two basic permissions (not all) – gotva Aug 01 '14 at 06:44
  • I only want to override one basic permission (I want to override :view_issues => so I can redefine it that it does not grant access to reports, which I want to seperate in an extra permission), not all, but I dont know to to achieve this goal. – kevdev Aug 01 '14 at 07:33
  • look at this [file](https://github.com/redmine/redmine/blob/2.5-stable/lib/redmine/access_control.rb) - it seems to me module does not have functionality to override permissions (line 23 - `mapper = Mapper.new`) and each time generates a new one. Maybe you can patch it or use another way to update value of instance `Mapper` or `Permission` – gotva Aug 01 '14 at 08:37

0 Answers0