diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-04-25 18:43:55 +0100 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-04-27 11:34:44 -0400 |
commit | 6ec67a69a815ba13bc0af93e9f54070595901d43 (patch) | |
tree | 139def3dc4aeef82e73832cad8927c68ad557bcc | |
parent | 328fe185d17fe395d2ee1042223b411485847f9d (diff) |
hide 'projects' and 'help' menus from normal users
-rw-r--r-- | app/models/group.rb | 8 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | lib/redmine.rb | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index d94ef753c..0cff0eaea 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -106,6 +106,14 @@ class Group < Principal GroupNonMember.load_instance end + def self.hacker + @@hacker ||= (Group.where :lastname => 'Hackers').first + end + + def self.community + @@community ||= (Group.where :lastname => 'Community').first + end + private # Removes references that are not handled by associations diff --git a/app/models/user.rb b/app/models/user.rb index 357856609..09d30ed24 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -664,6 +664,10 @@ class User < Principal end end + def is_vip? + (is_or_belongs_to? Group.hacker) || (is_or_belongs_to? Group.community) + end + # Return true if the user is allowed to do the specified action on a specific context # Action can be: # * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit') diff --git a/lib/redmine.rb b/lib/redmine.rb index 7773e3875..dfc4edf19 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -189,9 +189,9 @@ end Redmine::MenuManager.map :top_menu do |menu| menu.push :home, :home_path menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } - menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural + menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural, :if => Proc.new { User.current.is_vip? } menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true - menu.push :help, Redmine::Info.help_url, :last => true + menu.push :help, Redmine::Info.help_url, :if => Proc.new { User.current.is_vip? }, :last => true end Redmine::MenuManager.map :account_menu do |menu| |