forked from danmunn/redmine_dmsf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
146 lines (130 loc) · 5.84 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011 Vít Jonáš <[email protected]>
# Copyright (C) 2012 Daniel Munn <[email protected]>
# Copyright (C) 2011-14 Karel Picman <[email protected]>
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'redmine'
require 'redmine_dmsf'
require 'zip'
Redmine::Plugin.register :redmine_dmsf do
name 'DMSF'
author 'Vit Jonas / Daniel Munn / Karel Picman'
description 'Document Management System Features'
version '1.4.8 stable'
url 'http://www.redmine.org/plugins/dmsf'
author_url 'https://github.com/danmunn/redmine_dmsf/graphs/contributors'
requires_redmine :version_or_higher => '2.3.0'
settings :partial => 'settings/dmsf_settings',
:default => {
'dmsf_max_file_upload' => '0',
'dmsf_max_file_download' => '0',
'dmsf_max_email_filesize' => '0',
'dmsf_max_ajax_upload_filesize' => '100',
'dmsf_storage_directory' => Rails.root.join('files/dmsf').to_s,
'dmsf_index_database' => Rails.root.join('files/dmsf_index').to_s,
'dmsf_stemming_lang' => 'english',
'dmsf_stemming_strategy' => 'STEM_NONE',
'dmsf_webdav' => '1',
'dmsf_display_notified_recipients' => 0
}
menu :project_menu, :dmsf, { :controller => 'dmsf', :action => 'show' }, :caption => :menu_dmsf, :before => :documents, :param => :id
activity_provider :dmsf_files, :class_name => 'DmsfFileRevision', :default => true
project_module :dmsf do
permission :view_dmsf_folders,
{:dmsf => [:show],
:dmsf_folders_copy => [:new, :copy_to, :move_to]},
:read => true
permission :user_preferences,
{:dmsf_state => [:user_pref_save]}
permission :view_dmsf_files,
{:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed],
:dmsf_files => [:show],
:dmsf_files_copy => [:new, :create, :move],
:dmsf_workflows => [:log]},
:read => true
permission :folder_manipulation,
{:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root, :lock, :unlock, :notify_activate, :notify_deactivate, :delete_entries]}
permission :file_manipulation,
{:dmsf_files => [:create_revision, :delete, :lock, :unlock, :delete_revision, :notify_activate, :notify_deactivate],
:dmsf_upload => [:upload_files, :upload_file, :commit_files],
:dmsf_workflows => [:action, :new_action, :autocomplete_for_user, :start, :assign, :assignment],
:dmsf_links => [:new, :create, :destroy]
}
permission :manage_workflows,
{:dmsf_workflows => [:index, :new, :create, :destroy, :show, :add_step, :remove_step, :reorder_steps, :update]}
permission :force_file_unlock, {}
end
# Administration menu extension
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :approvalworkflows, {:controller => 'dmsf_workflows', :action => 'index'}, :caption => :label_dmsf_workflow_plural
end
Redmine::WikiFormatting::Macros.register do
desc "Wiki link to DMSF file:\n\n" +
"!{{dmsf(file_id [, title [, revision_id]])}}\n\n" +
"_file_id_ / _revision_id_ can be found in link for file/revision download."
macro :dmsf do |obj, args|
return nil if args.length < 1 # require file id
entry_id = args[0].strip
entry = DmsfFile.find(entry_id)
unless entry.nil? || entry.deleted
title = args[1] ? args[1] : entry.title
revision = args[2] ? args[2] : ''
return link_to "#{title}", :controller => 'dmsf_files', :action => 'show', :id => entry, :download => revision, :only_path => false
end
nil
end
end
Redmine::WikiFormatting::Macros.register do
desc "Wiki link to DMSF folder:\n\n" +
"!{{dmsff(folder_id [, title])}}\n\n" +
"_folder_id_ may be missing. _folder_id_ can be found in link for folder opening."
macro :dmsff do |obj, args|
if args.length < 1
return link_to l(:link_documents), :controller => 'dmsf', :action => 'show', :id => @project, :only_path => false
else
entry_id = args[0].strip
entry = DmsfFolder.find(entry_id)
unless entry.nil?
title = args[1] ? args[1] : entry.title
return link_to "#{title}", :controller => 'dmsf', :action => 'show', :id => entry.project, :folder_id => entry, :only_path => false
end
end
nil
end
end
Redmine::WikiFormatting::Macros.register do
desc "Wiki link to DMSF document description:\n\n" +
"{{dmsfd(file_id [, title])}}\n\n" +
"_file_id_ / _revision_id_ can be found in link for file/revision download."
macro :dmsfd do |obj, args|
return nil if args.length < 1 # require file id
entry_id = args[0].strip
entry = DmsfFile.find(entry_id)
unless entry.nil? || entry.deleted
title = args[1] ? args[1] : entry.title
return link_to "#{title}", :controller => 'dmsf_files', :action => 'show', :id => entry, :only_path => false
end
nil
end
end
# Rubyzip configuration
Zip.unicode_names = true
end
Redmine::Search.map do |search|
search.register :dmsf_files
search.register :dmsf_folders
end