forked from arkhitech/redmine_timesheet_plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
init.rb
55 lines (52 loc) · 1.81 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "redmine"
if Rails::VERSION::MAJOR < 3
require "dispatcher"
object_to_prepare = Dispatcher
else
object_to_prepare = Rails.configuration
# if redmine plugins were railties:
# object_to_prepare = config
end
object_to_prepare.to_prepare do
require_dependency "project"
require_dependency "principal"
require_dependency "user"
require_dependency "time_entry"
Project.send(:include, RedmineTimesheet::Patches::ProjectPatch)
User.send(:include, RedmineTimesheet::Patches::UserPatch)
TimeEntry.send(:include, RedmineTimesheet::Patches::TimeEntryPatch)
begin
require_dependency "time_entry_activity"
rescue LoadError
# TimeEntryActivity is not available
end
end
unless Redmine::Plugin.registered_plugins.keys.include?(:redmine_timesheet)
Redmine::Plugin.register :redmine_timesheet do
author "Arkhitech"
author_url "https://github.com/arkhitech"
description "This is a Timesheet plugin for Redmine to show timelogs for all projects"
name "Redmine Timesheet Plugin"
requires_redmine :version_or_higher => "2.0.0"
url "http://github.com/intera/redmine_timesheet"
version "0.8.0"
settings(:default => {
"list_size" => "5",
"precision" => "2",
"project_status" => "active",
"user_status" => "active"
}, :partial => "settings/timesheet_settings")
project_module :timesheet do
permission :see_all_timesheets, {}
end
menu(:top_menu,
:timesheet,
{:controller => :timesheet, :action => :index},
:caption => :timesheet_title,
:if => Proc.new {
User.current.allowed_to?(:view_time_entries, nil, :global => true) or
User.current.allowed_to?(:see_all_timesheets, nil, :global => true) or
User.current.admin?
})
end
end