This repository has been archived by the owner on May 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.rb
40 lines (27 loc) · 1.9 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'redmine'
Redmine::Plugin.register :appmenuadds do
name 'Redmine Application Menu Adds plugin'
author 'Romain Georges'
url 'https://www.ultragreen.net/projects/show/redmine-appmenuadds'
author_url 'http://www.ultragreen.net'
description 'This is a plugin for Redmine to add tabs in the Redmine Application Menu'
version '1.4.4'
menu :account_menu, :appmenuadds, { :controller => 'menutabs', :action => 'index' }, :caption => "Menu" , :after => :my_account, :if => Proc.new { User.current.admin? }
#hack to push existing links
require 'menutab'
if Menutab.table_exists? then
menulist = Menutab.find(:all, :order => :position)
menulist.each {|menutab|
if menutab.wiki_type == 'custom' then
Redmine::MenuManager.map(:application_menu).push menutab.label.to_sym, { :controller => 'menutabs', :action => 'view', :id => menutab.id},
:caption => Proc.new{|proj| menutab.label} unless Redmine::MenuManager.map(:application_menu).exists?(menutab.label.to_sym)
elsif menutab.wiki_type == 'project' then
Redmine::MenuManager.map(:application_menu).push menutab.label.to_sym, { :controller => 'menutabs', :action => 'forward_wiki_page', :wiki_page => menutab.wiki_page, :target_project => menutab.project },
:caption => Proc.new{|proj| menutab.label} unless Redmine::MenuManager.map(:application_menu).exists?(menutab.label.to_sym)
elsif menutab.wiki_type == 'external' then
Redmine::MenuManager.map(:application_menu).push menutab.label.to_sym, { :controller => 'menutabs', :action => 'external_page', :external_link => menutab.external_link },
:caption => Proc.new{|proj| menutab.label} unless Redmine::MenuManager.map(:application_menu).exists?(menutab.label.to_sym)
end
}
end
end