redmine.rb 10.4 KB
Newer Older
1 2
require 'redmine/access_control'
require 'redmine/menu_manager'
3
require 'redmine/activity'
4
require 'redmine/search'
5
require 'redmine/custom_field_format'
6
require 'redmine/mime_type'
7
require 'redmine/core_ext'
8
require 'redmine/themes'
9
require 'redmine/hook'
10
require 'redmine/plugin'
11
require 'redmine/wiki_formatting'
12
require 'redmine/scm/base'
13

14
begin
15
  require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
16 17 18 19
rescue LoadError
  # RMagick is not available
end

20 21 22 23 24 25 26
if RUBY_VERSION < '1.9'
  require 'faster_csv'
else
  require 'csv'
  FCSV = CSV
end

27 28 29 30 31 32 33
Redmine::Scm::Base.add "Subversion"
Redmine::Scm::Base.add "Darcs"
Redmine::Scm::Base.add "Mercurial"
Redmine::Scm::Base.add "Cvs"
Redmine::Scm::Base.add "Bazaar"
Redmine::Scm::Base.add "Git"
Redmine::Scm::Base.add "Filesystem"
34

35 36 37 38 39 40 41 42 43 44
Redmine::CustomFieldFormat.map do |fields|
  fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1)
  fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2)
  fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3)
  fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4)
  fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5)
  fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6)
  fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7)
end

45 46
# Permissions
Redmine::AccessControl.map do |map|
47
  map.permission :view_project, {:projects => [:show, :activity]}, :public => true
48
  map.permission :search_project, {:search => :index}, :public => true
49
  map.permission :add_project, {:projects => :add}, :require => :loggedin
50
  map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
51
  map.permission :select_project_modules, {:projects => :modules}, :require => :member
52
  map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
53
  map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
54
  map.permission :add_subprojects, {:projects => :add}, :require => :member
55
  
56 57
  map.project_module :issue_tracking do |map|
    # Issue categories
58
    map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
59
    # Issues
60
    map.permission :view_issues, {:projects => :roadmap, 
61
                                  :issues => [:index, :changes, :show, :context_menu, :auto_complete],
62
                                  :versions => [:show, :status_by],
63
                                  :queries => :index,
64
                                  :reports => [:issue_report, :issue_report_details]}
65
    map.permission :add_issues, {:issues => [:new, :create, :update_form]}
66
    map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]}
67
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
68
    map.permission :manage_subtasks, {}
69
    map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]}
70 71
    map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
    map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
72
    map.permission :move_issues, {:issues => :move}, :require => :loggedin
73 74
    map.permission :delete_issues, {:issues => :destroy}, :require => :member
    # Queries
75
    map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
76 77
    map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
    # Gantt & calendar
78
    map.permission :view_gantt, :gantts => :show
79
    map.permission :view_calendar, :calendars => :show
80 81 82
    # Watchers
    map.permission :view_issue_watchers, {}
    map.permission :add_issue_watchers, {:watchers => :new}
83
    map.permission :delete_issue_watchers, {:watchers => :destroy}
84 85 86 87 88
  end
  
  map.project_module :time_tracking do |map|
    map.permission :log_time, {:timelog => :edit}, :require => :loggedin
    map.permission :view_time_entries, :timelog => [:details, :report]
89 90
    map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
    map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
91
    map.permission :manage_project_activities, {:projects => [:save_activities, :reset_activities]}, :require => :member
92 93 94
  end
  
  map.project_module :news do |map|
95
    map.permission :manage_news, {:news => [:new, :edit, :destroy, :destroy_comment]}, :require => :member
96
    map.permission :view_news, {:news => [:index, :show]}, :public => true
97
    map.permission :comment_news, {:news => :add_comment}
98 99 100
  end

  map.project_module :documents do |map|
101
    map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin
102
    map.permission :view_documents, :documents => [:index, :show, :download]
103 104 105
  end
  
  map.project_module :files do |map|
106
    map.permission :manage_files, {:projects => :add_file}, :require => :loggedin
107 108 109 110 111 112 113
    map.permission :view_files, :projects => :list_files, :versions => :download
  end
    
  map.project_module :wiki do |map|
    map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member
    map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member
    map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member
114
    map.permission :view_wiki_pages, :wiki => [:index, :special]
115
    map.permission :export_wiki_pages, {}
116
    map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
117
    map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment]
118
    map.permission :delete_wiki_pages_attachments, {}
119
    map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
120 121 122
  end
    
  map.project_module :repository do |map|
123
    map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
124
    map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
125
    map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
126
    map.permission :commit_access, {}
127 128 129 130 131
  end

  map.project_module :boards do |map|
    map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
    map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
132
    map.permission :add_messages, {:messages => [:new, :reply, :quote]}
133
    map.permission :edit_messages, {:messages => :edit}, :require => :member
134
    map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
135
    map.permission :delete_messages, {:messages => :destroy}, :require => :member
136
    map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
137
  end
138 139
end

140
Redmine::MenuManager.map :top_menu do |menu|
141 142 143 144 145
  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 :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true
  menu.push :help, Redmine::Info.help_url, :last => true
146 147 148
end

Redmine::MenuManager.map :account_menu do |menu|
149 150 151 152
  menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? }
  menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? }
  menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? }
  menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? }
153 154 155 156 157 158
end

Redmine::MenuManager.map :application_menu do |menu|
  # Empty
end

159 160 161 162
Redmine::MenuManager.map :admin_menu do |menu|
  # Empty
end

163
Redmine::MenuManager.map :project_menu do |menu|
164 165
  menu.push :overview, { :controller => 'projects', :action => 'show' }
  menu.push :activity, { :controller => 'projects', :action => 'activity' }
166
  menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, 
167
              :if => Proc.new { |p| p.shared_versions.any? }
168
  menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
169 170
  menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
              :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
171 172 173
  menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
  menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural
  menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, 
174
              :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
175 176
  menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
              :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
177
  menu.push :files, { :controller => 'projects', :action => 'list_files' }, :caption => :label_file_plural
178
  menu.push :repository, { :controller => 'repositories', :action => 'show' },
179
              :if => Proc.new { |p| p.repository && !p.repository.new_record? }
180
  menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
181
end
182 183 184 185 186 187 188

Redmine::Activity.map do |activity|
  activity.register :issues, :class_name => %w(Issue Journal)
  activity.register :changesets
  activity.register :news
  activity.register :documents, :class_name => %w(Document Attachment)
  activity.register :files, :class_name => 'Attachment'
189
  activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
190
  activity.register :messages, :default => false
191
  activity.register :time_entries, :default => false
192
end
193

194 195 196 197 198 199 200 201 202 203
Redmine::Search.map do |search|
  search.register :issues
  search.register :news
  search.register :documents
  search.register :changesets
  search.register :wiki_pages
  search.register :messages
  search.register :projects
end

204 205 206
Redmine::WikiFormatting.map do |format|
  format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
end