redmine.rb 13.2 KB
Newer Older
1
#-- encoding: UTF-8
2 3
#-- copyright
# ChiliProject is a project management system.
4
#
Holger Just's avatar
Holger Just committed
5
# Copyright (C) 2010-2012 the ChiliProject Team
6
#
7 8 9 10
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
11
#
12 13 14
# See doc/COPYRIGHT.rdoc for more details.
#++

15 16
require 'redmine/access_control'
require 'redmine/menu_manager'
17
require 'redmine/activity'
18
require 'redmine/search'
19
require 'redmine/custom_field_format'
20
require 'redmine/mime_type'
21
require 'redmine/core_ext'
22
require 'redmine/themes'
23
require 'redmine/hook'
24
require 'redmine/plugin'
25
require 'redmine/notifiable'
26
require 'redmine/wiki_formatting'
27
require 'redmine/scm/base'
28

29
begin
30
  require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
31 32 33 34
rescue LoadError
  # RMagick is not available
end

35 36 37 38 39 40 41
if RUBY_VERSION < '1.9'
  require 'faster_csv'
else
  require 'csv'
  FCSV = CSV
end

42 43 44 45 46 47 48
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"
49

50 51 52 53 54 55 56 57
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)
58 59
  fields.register Redmine::CustomFieldFormat.new('user', :label => :label_user, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 8)
  fields.register Redmine::CustomFieldFormat.new('version', :label => :label_version, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 9)
60 61
end

62 63
# Permissions
Redmine::AccessControl.map do |map|
64
  map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true
65
  map.permission :search_project, {:search => :index}, :public => true
66
  map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
67
  map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
68
  map.permission :select_project_modules, {:projects => :modules}, :require => :member
69
  map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
70
  map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
71
  map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
72

73 74
  map.project_module :issue_tracking do |map|
    # Issue categories
75
    map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
76
    # Issues
77
    map.permission :view_issues, {:issues => [:index, :show],
78
                                  :auto_complete => [:issues],
79
                                  :context_menus => [:issues],
80
                                  :versions => [:index, :show, :status_by],
81
                                  :journals => [:index, :diff],
82
                                  :queries => :index,
83
                                  :reports => [:issue_report, :issue_report_details]}
84
    map.permission :add_issues, {:issues => [:new, :create, :update_form]}
85
    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]}
86
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
87
    map.permission :manage_subtasks, {}
88
    map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]}
89 90
    map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
    map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
91
    map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin
92 93
    map.permission :delete_issues, {:issues => :destroy}, :require => :member
    # Queries
94
    map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member
95
    map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin
96 97 98
    # Watchers
    map.permission :view_issue_watchers, {}
    map.permission :add_issue_watchers, {:watchers => :new}
99
    map.permission :delete_issue_watchers, {:watchers => :destroy}
100
  end
101

102
  map.project_module :time_tracking do |map|
103
    map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin
104
    map.permission :view_time_entries, :timelog => [:index, :show], :time_entry_reports => [:report]
105 106
    map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy]}, :require => :member
    map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy]}, :require => :loggedin
107
    map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
108
  end
109

110
  map.project_module :news do |map|
111
    map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
112
    map.permission :view_news, {:news => [:index, :show]}, :public => true
113
    map.permission :comment_news, {:comments => :create}
114 115 116
  end

  map.project_module :documents do |map|
117
    map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin
118
    map.permission :view_documents, :documents => [:index, :show, :download]
119
  end
120

121
  map.project_module :files do |map|
122
    map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin
123
    map.permission :view_files, :files => :index, :versions => :download
124
  end
125

126 127 128 129
  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
130
    map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index]
131
    map.permission :export_wiki_pages, :wiki => [:export]
132
    map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate]
133
    map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment]
134
    map.permission :delete_wiki_pages_attachments, {}
135
    map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member
136
  end
137

138
  map.project_module :repository do |map|
139
    map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
140
    map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph]
141
    map.permission :view_changesets, :repositories => [:show, :revisions, :revision]
142
    map.permission :commit_access, {}
143 144 145 146 147
  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
148
    map.permission :add_messages, {:messages => [:new, :reply, :quote]}
149
    map.permission :edit_messages, {:messages => :edit}, :require => :member
150
    map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin
151
    map.permission :delete_messages, {:messages => :destroy}, :require => :member
152
    map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin
153
  end
154 155

  map.project_module :calendar do |map|
156
    map.permission :view_calendar, :calendars => [:show, :update]
157 158 159
  end

  map.project_module :gantt do |map|
160
    map.permission :view_gantt, :gantts => [:show, :update]
161
  end
162 163
end

164
Redmine::MenuManager.map :top_menu do |menu|
165 166 167 168 169
  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
170 171 172
end

Redmine::MenuManager.map :account_menu do |menu|
173 174 175 176
  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? }
177 178 179 180 181 182
end

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

183
Redmine::MenuManager.map :admin_menu do |menu|
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
  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
200 201
end

202
Redmine::MenuManager.map :project_menu do |menu|
203
  menu.push :overview, { :controller => 'projects', :action => 'show' }
204
  menu.push :activity, { :controller => 'activities', :action => 'index' }
205
  menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
206
              :if => Proc.new { |p| p.shared_versions.any? }
207
  menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
208 209
  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
210 211
  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
212 213
  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
214
  menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
215
              :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
216 217
  menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
              :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
218
  menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
219
  menu.push :repository, { :controller => 'repositories', :action => 'show' },
220
              :if => Proc.new { |p| p.repository && !p.repository.new_record? }
221
  menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
222
end
223 224

Redmine::Activity.map do |activity|
225
  activity.register :issues, :class_name => 'Issue'
226 227 228 229
  activity.register :changesets
  activity.register :news
  activity.register :documents, :class_name => %w(Document Attachment)
  activity.register :files, :class_name => 'Attachment'
230
  activity.register :wiki_edits, :class_name => 'WikiContent', :default => false
231
  activity.register :messages, :default => false
232
  activity.register :time_entries, :default => false
233
end
234

235 236 237 238 239 240 241 242 243 244
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

245 246 247
Redmine::WikiFormatting.map do |format|
  format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
end
248

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