forked from Intera/redmine_timesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
65 lines (56 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'redmine'
## Taken from lib/redmine.rb
#if RUBY_VERSION < '1.9'
# require 'faster_csv'
#else
# require 'csv'
# FCSV = CSV
#end
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'
Project.send(:include, RedmineTimesheetPlugin::Patches::ProjectPatch)
User.send(:include, RedmineTimesheetPlugin::Patches::UserPatch)
# Needed for the compatibility check
begin
require_dependency 'time_entry_activity'
rescue LoadError
# TimeEntryActivity is not available
end
end
unless Redmine::Plugin.registered_plugins.keys.include?(:redmine_timesheet_plugin)
Redmine::Plugin.register :redmine_timesheet_plugin do
name 'Redmine Timesheet Plugin'
author 'Hisham Malik'
description 'This is a Timesheet plugin for Redmine to show timelogs for all projects'
url 'http://github.com/techarete/redmine_timesheet_plugin'
author_url 'https://github.com/hishammalik'
version '0.7.0'
requires_redmine :version_or_higher => '0.9.0'
settings(:default => {
'list_size' => '5',
'precision' => '2',
'project_status' => 'active',
'user_status' => 'active'
}, :partial => 'settings/timesheet_settings')
permission :see_project_timesheets, { }, :require => :member
menu(:top_menu,
:timesheet,
{:controller => :timesheet, :action => :index},
:caption => :timesheet_title,
:if => Proc.new {
User.current.allowed_to?(:see_project_timesheets, nil, :global => true) ||
User.current.allowed_to?(:view_time_entries, nil, :global => true) ||
User.current.admin?
})
end
end