Project specific development

Added by Peter I almost 9 years ago

Hello there,

currently I am modifying redmine a lot.

But I stuck on that part:

To hide the menu link "Activity" from a specific project.

My first try was that:

lib/redmine.rb - Line 239
menu.push :activity, { :controller => 'activities', :action => 'index' }, :if => Proc.new { Project.id==1 }

But I guess Project is undefined at the moment when this file is loaded.
Even though there is this nice plugin api. Which got this method:

delete_menu_item

But how would I tell my plugin something like that:

if(Project.id == 1) then delete_menu_item(:project_menu, :activity) end

I guess both methods would work. But I can't get them working.

  Redmine version                2.3.2.stable
  Ruby version                   1.9.3-p194 (2012-04-20) [x86_64-linux]
  Rails version                  3.2.13
  Environment                    production
  Database adapter               Mysql2

Replies (2)

RE: Project specific development - Added by Arnaud Martel almost 9 years ago

Peter I wrote:

My first try was that:

lib/redmine.rb - Line 239
menu.push :activity, { :controller => 'activities', :action => 'index' }, :if => Proc.new { Project.id==1 }

I think your code is wrong. I have patched redmine.rb at the same line and I used, with success, the following syntax:
menu.push :activity, { :controller => 'activities', :action => 'index' }, :if => Proc.new{|project| User.current.admin? || User.current.allowed_to?(:custom_view_activity, project)}

so, in your example, you should have:
menu.push :activity, { :controller => 'activities', :action => 'index' }, :if => Proc.new {|project| project.id==1 }

RE: Project specific development - Added by Peter I almost 9 years ago

Well that is the solution. Thank you for that.

(1-2/2)