redmine.rb 12.5 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/notifiable'
12
require 'redmine/wiki_formatting'
13
require 'redmine/scm/base'
14

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

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

28 29 30 31 32 33 34
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"
35

36 37 38 39 40 41 42 43 44 45
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

46 47
# Permissions
Redmine::AccessControl.map do |map|
48
  map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
49
  map.permission :search_project, {:search => :index}, :public => true
50
  map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
51
  map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
52
  map.permission :select_project_modules, {:projects => :modules}, :require => :member
53
  map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
54
  map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
55
  map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
56
  
57 58
  map.project_module :issue_tracking do |map|
    # Issue categories
59
    map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
60
    # Issues
61
    map.permission :view_issues, {:issues => [:index, :show],
62
                                  :auto_complete => [:issues],
63
                                  :context_menus => [:issues],
64
                                  :versions => [:index, :show, :status_by],
65
                                  :journals => :index,
66
                                  :queries => :index,
67
                                  :reports => [:issue_report, :issue_report_details]}
68
    map.permission :add_issues, {:issues => [:new, :create, :update_form]}
69
    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
70
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
71
    map.permission :manage_subtasks, {}
72
    map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
73 74
    map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
    map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
75
    map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin
76 77
    map.permission :delete_issues, {:issues => :destroy}, :require => :member
    # Queries
78
    map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
79
    map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
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
  end
  
  map.project_module :time_tracking do |map|
87
    map.permission :log_time, {:timelog => [:new, :create, :edit, :update]}, :require => :loggedin
88
    map.permission :view_time_entries, :timelog => [:index, :show], :time_entry_reports => [:report]
89 90
    map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :member
    map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
91
    map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
92 93 94
  end
  
  map.project_module :news do |map|
95
    map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
96
    map.permission :view_news, {:news => [:index, :show]}, :public => true
97
    map.permission :comment_news, {:comments => :create}
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, {:files => [:new, :create]}, :require => :loggedin
107
    map.permission :view_files, :files => :index, :versions => :download
108 109 110 111 112 113
  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, :show, :special, :date_index]
115
    map.permission :export_wiki_pages, :wiki => [:export]
116
    map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
117
    map.permission :edit_wiki_pages, :wiki => [:edit, :update, :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

  map.project_module :calendar do |map|
140
    map.permission :view_calendar, :calendars => [:show, :update]
141 142 143
  end

  map.project_module :gantt do |map|
144
    map.permission :view_gantt, :gantts => [:show, :update]
145
  end
146 147
end

148
Redmine::MenuManager.map :top_menu do |menu|
149 150 151 152 153
  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
154 155 156
end

Redmine::MenuManager.map :account_menu do |menu|
157 158 159 160
  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? }
161 162 163 164 165 166
end

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

167
Redmine::MenuManager.map :admin_menu do |menu|
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
  menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
  menu.push :users, {:controller => 'users'}, :caption => :label_user_plural
  menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural
  menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions
  menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural
  menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural,
            :html => {:class => 'issue_statuses'}
  menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow
  menu.push :custom_fields, {:controller => 'custom_fields'},  :caption => :label_custom_field_plural,
            :html => {:class => 'custom_fields'}
  menu.push :enumerations, {:controller => 'enumerations'}
  menu.push :settings, {:controller => 'settings'}
  menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'},
            :html => {:class => 'server_authentication'}
  menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true
  menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true
184 185
end

186
Redmine::MenuManager.map :project_menu do |menu|
187
  menu.push :overview, { :controller => 'projects', :action => 'show' }
188 189
  menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
              :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
190
  menu.push :activity, { :controller => 'activities', :action => 'index' }
191
  menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
192
              :if => Proc.new { |p| p.shared_versions.any? }
193
  menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
194 195
  menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new,
              :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
196 197
  menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
  menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
198 199 200 201
  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 :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
              :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
202
  menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
203
  menu.push :repository, { :controller => 'repositories', :action => 'show' },
204
              :if => Proc.new { |p| p.repository && !p.repository.new_record? }
205
  menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
206
end
207 208 209 210 211 212 213

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'
214
  activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
215
  activity.register :messages, :default => false
216
  activity.register :time_entries, :default => false
217
end
218

219 220 221 222 223 224 225 226 227 228
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

229 230 231
Redmine::WikiFormatting.map do |format|
  format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
end
232

233
ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler