summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2018-04-25 18:43:55 +0100
committerbill-auger <mr.j.spam.me@gmail.com>2018-04-27 11:05:24 -0400
commit6d4a8e4c2bc427eed5d0b4e503d75454ee607168 (patch)
treee4c19afd2da9024fb872d2ad06ec596666475058
parent0e365224729b2104d26dcb845e084a7b4379d49c (diff)
hide 'projects' and 'help' menus from normal users
-rw-r--r--app/models/group.rb8
-rw-r--r--app/models/user.rb4
-rw-r--r--lib/redmine.rb4
3 files changed, 14 insertions, 2 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 1362472b5..8562de86f 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 e90b44738..607661545 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -618,6 +618,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 71722cc8e..9c895e1e1 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -190,9 +190,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|