Merge pull request #2 from danmunn/master

Update from master
This commit is contained in:
mrak0s 2019-02-28 12:10:57 +01:00 committed by GitHub
commit b3f6aa7293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
300 changed files with 2126 additions and 1287 deletions

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -23,10 +23,10 @@ language: ruby
sudo: true
dist: trusty
dist: xenial
rvm:
- 2.4
- 2.5
before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS test CHARACTER SET utf8mb4;'

View File

@ -1,6 +1,30 @@
Changelog for Redmine DMSF
==========================
2.0.0 *2019-02-28*
------------------
Compatibility with Redmine 4.0
Russian localization updated
* Bug: #976 - Can't link document to issue with column in subject
* Bug: #969 - About the DMSF folder search logic
* Bug: #966 - folder_manipulation permission
* Bug: #965 - tag column missing in the dms_file_revision_table
* Bug: #959 - crete symbolic link error
* Bug: #956 - About "External" of "Link from"
* Bug: #950 - Wrong description, missing argument for macro {{dmsft}}
* Bug: #940 - dav4rack license
* Bug: #937 - Documents upload if disk is full
* Bug: #936 - Then go to configuration an internal error #500 appear
* Bug: #935 - Upload failure for 2.0
* Bug: #934 - problem to get reversion error
* Bug: #933 - změny v xapian_indexer
* Bug: #932 - undefined method `to_prepare' for ActionDispatch::Reloader:Class (Redmine 4.0 / Rails 5)
* Bug: #929 - Problems in revision history
* New: #928 - About Redmine 4.0.0
* New: #576 - Installation problem 1.5.7 (step 4 of the guide)
1.6.2 *2018-12-04*
------------------

View File

@ -4,7 +4,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -22,7 +22,7 @@
source 'https://rubygems.org'
gem 'rubyzip', '>= 1.0.0'
gem 'rubyzip', '>= 1.1.3'
gem 'zip-zip'
gem 'simple_enum'
gem 'uuidtools'
@ -35,3 +35,7 @@ end
# Dav4Rack
gem 'ox'
group :test do
gem 'rails-controller-testing'
end

View File

@ -1,7 +1,7 @@
Redmine DMSF Plugin
===================
The current version of Redmine DMSF is **1.6.2** [![Build Status](https://api.travis-ci.org/danmunn/redmine_dmsf.png)](https://travis-ci.org/danmunn/redmine_dmsf)
The current version of Redmine DMSF is **2.0.0** [![Build Status](https://api.travis-ci.org/danmunn/redmine_dmsf.png)](https://travis-ci.org/danmunn/redmine_dmsf)
Redmine DMSF is Document Management System Features plugin for Redmine issue tracking system; It is aimed to replace current Redmine's Documents module.
@ -38,12 +38,12 @@ Features
* Document tagging
* Trash bin
* Documents attachable to issues
* Compatible with Redmine 3.4.x
* Compatible with Redmine 4.0.x
Dependencies
------------
* Redmine 3.4.0 or higher
* Redmine 4.0.0 or higher
### Full-text search (optional)
@ -211,14 +211,20 @@ There's a patch (tested with Redmine 3.4.2) that helps you to modify all help fi
Setup / Upgrade
---------------
Before installing ensure that the Redmine instance is stopped.
You can either clone the master branch or download the latest zipped version. Before installing ensure that the Redmine instance is stopped.
1. In case of upgrade BACKUP YOUR DATABASE first
2. Put redmine_dmsf plugin directory into plugins.
git clone git@github.com:danmunn/redmine_dmsf.git
wget https://github.com/danmunn/redmine_dmsf/archive/master.zip
1. In case of upgrade **BACKUP YOUR DATABASE, ORIGINAL PLUGIN AND THE FOLDER WITH DOCUMENTS** first!!!
2. Put redmine_dmsf plugin directory into plugins. The plugins sub-directory must be named just **redmine_dmsf**. In case
of need rename _redmine_dmsf-x.y.z_ to *redmine_dmsf*.
3. **Go to the redmine directory** `cd redmine`
3. Install dependencies: `bundle install`.
4. Initialize/Update database: `bundle exec rake redmine:plugins:migrate RAILS_ENV="production"`.
4. Initialize/Update database: `bundle exec rake redmine:plugins:migrate NAME=redmine_dmsf RAILS_ENV="production"`.
5. The access rights must be set for web server, example: `chown -R www-data:www-data plugins/redmine_dmsf`.
6. Restart the web server.
6. Restart the web server. e.g. `service apache2 restart`
7. You should configure the plugin via Redmine interface: Administration -> Plugins -> DMSF -> Configure.
8. Assign DMSF permissions to appropriate roles.
9. There are a few rake tasks:
@ -279,13 +285,13 @@ It is necessary to index DMSF files with omindex before searching attempts to re
1. Change the configuration part of redmine_dmsf/extra/xapian_indexer.rb file according to your environment.
(The path to the index database set in xapian_indexer.rb must corresponds to the path set in the plugin's settings.)
2. Run `ruby redmine_dmsf/extra/xapian_indexer.rb -vf`
2. Run `ruby redmine_dmsf/extra/xapian_indexer.rb -v`
This command should be run on regular basis (e.g. from cron)
Example of cron job (once per hour at 8th minute):
8 * * * * root /usr/bin/ruby redmine_dmsf/extra/xapian_indexer.rb -f
8 * * * * root /usr/bin/ruby redmine_dmsf/extra/xapian_indexer.rb
See redmine_dmsf/extra/xapian_indexer.rb for help.

View File

@ -4,7 +4,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -23,6 +23,8 @@
require_dependency 'zip'
require_dependency File.dirname(__FILE__) + '/lib/redmine_dmsf.rb'
ActiveSupport::Dependencies.autoload_paths << File.join(File.dirname(__FILE__), 'app', 'validators')
def init
# Administration menu extension
Redmine::MenuManager.map :admin_menu do |menu|
@ -100,7 +102,7 @@ else
init
end
ActionDispatch::Reloader.to_prepare do
RedmineExtensions::Reloader.to_prepare do
# Rubyzip configuration
Zip.unicode_names = true

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -4,7 +4,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -21,6 +21,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class DmsfController < ApplicationController
include RedmineDmsf::DmsfZip
before_action :find_project
before_action :authorize, :except => [:expand_folder]
@ -93,7 +94,7 @@ class DmsfController < ApplicationController
:type => 'application/zip',
:disposition => 'attachment')
rescue Exception => e
flash[:error] = e.message
flash[:errors] = e.message
end
def entries_operation
@ -150,7 +151,7 @@ class DmsfController < ApplicationController
rescue DmsfAccessError
render_403 # and return
rescue StandardError => e
flash[:error] = e.message
flash[:errors] = e.message
Rails.logger.error e.message
end
end
@ -170,9 +171,9 @@ class DmsfController < ApplicationController
def entries_email
if params[:email][:to].strip.blank?
flash[:error] = l(:error_email_to_must_be_entered)
flash[:errors] = l(:error_email_to_must_be_entered)
else
DmsfMailer.send_documents(@project, params[:email]).deliver
DmsfMailer.deliver_send_documents(@project, params[:email].permit!)
File.delete(params[:email][:zipped_content])
flash[:notice] = l(:notice_email_sent, params[:email][:to])
end
@ -189,7 +190,6 @@ class DmsfController < ApplicationController
@parent = @folder.dmsf_folder
@pathfolder = copy_folder(@folder)
@force_file_unlock_allowed = User.current.allowed_to?(:force_file_unlock, @project)
@users = Principal.active.where(id: @folder.dmsf_folder_permissions.users.map{ |p| p.object_id })
end
def create
@ -247,7 +247,7 @@ class DmsfController < ApplicationController
if result
flash[:notice] = l(:notice_folder_deleted)
else
flash[:error] = @folder.errors.full_messages.to_sentence
flash[:errors] = @folder.errors.full_messages.to_sentence
end
respond_to do |format|
format.html do
@ -265,7 +265,7 @@ class DmsfController < ApplicationController
if @folder.restore
flash[:notice] = l(:notice_dmsf_folder_restored)
else
flash[:error] = @folder.errors.full_messages.to_sentence
flash[:errors] = @folder.errors.full_messages.to_sentence
end
redirect_to :back
end
@ -279,7 +279,7 @@ class DmsfController < ApplicationController
if @project.save
flash[:notice] = l(:notice_folder_details_were_saved)
else
flash[:error] = @project.errors.full_messages.to_sentence
flash[:errors] = @project.errors.full_messages.to_sentence
end
end
redirect_to dmsf_folder_path(:id => @project)
@ -337,7 +337,7 @@ class DmsfController < ApplicationController
@folder.unlock!
flash[:notice] = l(:notice_folder_unlocked)
else
flash[:error] = l(:error_only_user_that_locked_folder_can_unlock_it)
flash[:errors] = l(:error_only_user_that_locked_folder_can_unlock_it)
end
end
redirect_to :back
@ -366,15 +366,16 @@ class DmsfController < ApplicationController
end
def email_entries(selected_folders, selected_files)
zip = DmsfZip.new
zip = Zip.new
zip_entries(zip, selected_folders, selected_files)
zipped_content = DmsfHelper.temp_dir.join(DmsfHelper.temp_filename('dmsf_email_sent_documents.zip'))
File.open(zipped_content, 'wb') do |f|
zip_file = File.open(zip.finish, 'rb')
while (buffer = zip_file.read(8192))
f.write(buffer)
File.open(zip.finish, 'rb') do |zip_file|
while (buffer = zip_file.read(8192))
f.write(buffer)
end
end
end
@ -396,8 +397,8 @@ class DmsfController < ApplicationController
:folders => selected_folders,
:files => selected_files,
:subject => "#{@project.name} #{l(:label_dmsf_file_plural).downcase}",
:from => Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].blank? ?
"#{User.current.name} <#{User.current.mail}>" : Setting.plugin_redmine_dmsf['dmsf_documents_email_from'],
:from => Setting.plugin_redmine_dmsf['dmsf_documents_email_from'].presence ||
"#{User.current.name} <#{User.current.mail}>",
:reply_to => Setting.plugin_redmine_dmsf['dmsf_documents_email_reply_to']
}
render :action => 'email_entries'
@ -408,7 +409,7 @@ class DmsfController < ApplicationController
end
def download_entries(selected_folders, selected_files)
zip = DmsfZip.new
zip = Zip.new
zip_entries(zip, selected_folders, selected_files)
zip.files.each do |f|
audit = DmsfFileRevisionAccess.new
@ -428,7 +429,7 @@ class DmsfController < ApplicationController
end
def zip_entries(zip, selected_folders, selected_files)
member = Member.where(user_id: User.current.id, project_id: @project.id).first
member = Member.find_by(user_id: User.current.id, project_id: @project.id)
selected_folders.each do |selected_folder_id|
folder = DmsfFolder.visible.find_by(id: selected_folder_id)
if folder
@ -460,7 +461,7 @@ class DmsfController < ApplicationController
folder = DmsfFolder.find_by(id: id)
if folder
unless folder.restore
flash[:error] = folder.errors.full_messages.to_sentence
flash[:errors] = folder.errors.full_messages.to_sentence
end
else
raise FileNotFound
@ -471,7 +472,7 @@ class DmsfController < ApplicationController
file = DmsfFile.find_by(id: id)
if file
unless file.restore
flash[:error] = file.errors.full_messages.to_sentence
flash[:errors] = file.errors.full_messages.to_sentence
end
else
raise FileNotFound
@ -482,7 +483,7 @@ class DmsfController < ApplicationController
link = DmsfLink.find_by(id: id)
if link
unless link.restore
flash[:error] = link.errors.full_messages.to_sentence
flash[:errors] = link.errors.full_messages.to_sentence
end
else
raise FileNotFound
@ -493,10 +494,11 @@ class DmsfController < ApplicationController
def delete_entries(selected_folders, selected_files, selected_dir_links, selected_file_links, selected_url_links, commit)
# Folders
selected_folders.each do |id|
raise DmsfAccessError unless User.current.allowed_to?(:folder_manipulation, @project)
folder = DmsfFolder.find_by(id: id)
if folder
unless folder.delete commit
flash[:error] = folder.errors.full_messages.to_sentence
flash[:errors] = folder.errors.full_messages.to_sentence
return
end
elsif !commit
@ -521,12 +523,9 @@ class DmsfController < ApplicationController
# Activities
unless deleted_files.empty?
begin
recipients = DmsfMailer.get_notify_users(@project, deleted_files)
recipients.each do |u|
DmsfMailer.files_deleted(u, @project, deleted_files).deliver
end
recipients = DmsfMailer.deliver_files_deleted(@project, deleted_files)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.empty?
if recipients.any?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
@ -544,7 +543,7 @@ class DmsfController < ApplicationController
link = DmsfLink.find_by(id: id)
link.delete commit if link
end
if flash[:error].blank? && flash[:warning].blank?
if flash[:errors].blank? && flash[:warning].blank?
flash[:notice] = l(:notice_entries_deleted)
end
end
@ -681,7 +680,7 @@ class DmsfController < ApplicationController
@subfolders = DmsfHelper.visible_folders(@subfolders, @project)
end
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].presence || 100
# Trash
@trash_visible = @folder_manipulation_allowed && @file_manipulation_allowed &&

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -57,7 +57,7 @@ class DmsfFilesController < ApplicationController
access.dmsf_file_revision = @revision
access.action = DmsfFileRevisionAccess::DownloadAction
access.save!
member = Member.where(user_id: User.current.id, project_id: @file.project.id).first
member = Member.find_by(user_id: User.current.id, project_id: @file.project.id)
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
title_format = member.dmsf_title_format
else
@ -95,7 +95,7 @@ class DmsfFilesController < ApplicationController
def create_revision
if params[:dmsf_file_revision]
if @file.locked_for_user?
flash[:error] = l(:error_file_is_locked)
flash[:errors] = l(:error_file_is_locked)
else
revision = DmsfFileRevision.new
revision.title = params[:dmsf_file_revision][:title]
@ -139,8 +139,10 @@ class DmsfFilesController < ApplicationController
# Custom fields
if params[:dmsf_file_revision][:custom_field_values].present?
params[:dmsf_file_revision][:custom_field_values].each_with_index do |v, i|
revision.custom_field_values[i].value = v[1]
i = 0
params[:dmsf_file_revision][:custom_field_values].each do |_, v|
revision.custom_field_values[i].value = v
i = i + 1
end
end
@ -149,39 +151,44 @@ class DmsfFilesController < ApplicationController
if revision.save
revision.assign_workflow(params[:dmsf_workflow_id])
if upload
FileUtils.mv(upload.tempfile_path, revision.disk_file(false))
begin
FileUtils.mv(upload.tempfile_path, revision.disk_file(false))
rescue StandardError => e
Rails.logger.error e.message
flash[:error] = e.message
revision.destroy
redirect_to :back
return
end
end
if @file.locked? && !@file.locks.empty?
begin
@file.unlock!
flash[:notice] = "#{l(:notice_file_unlocked)}, "
rescue Exception => e
logger.error "Cannot unlock the file: #{e.message}"
Rails.logger.error "Cannot unlock the file: #{e.message}"
end
end
if @file.save
@file.set_last_revision revision
flash[:notice] = (flash[:notice].nil? ? '' : flash[:notice]) + l(:notice_file_revision_created)
begin
recipients = DmsfMailer.get_notify_users(@project, [@file])
recipients.each do |u|
DmsfMailer.files_updated(u, @project, [@file]).deliver
end
recipients = DmsfMailer.deliver_files_updated(@project, [@file])
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.empty?
if recipients.any?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
end
end
rescue Exception => e
logger.error "Could not send email notifications: #{e.message}"
Rails.logger.error "Could not send email notifications: #{e.message}"
end
else
flash[:error] = @file.errors.full_messages.join(', ')
flash[:errors] = @file.errors.full_messages.join(', ')
end
else
flash[:error] = revision.errors.full_messages.join(', ')
flash[:errors] = revision.errors.full_messages.join(', ')
end
end
end
@ -196,12 +203,9 @@ class DmsfFilesController < ApplicationController
flash[:notice] = l(:notice_file_deleted)
unless commit
begin
recipients = DmsfMailer.get_notify_users(@project, [@file])
recipients.each do |u|
DmsfMailer.files_deleted(u, @project, [@file]).deliver
end
recipients = DmsfMailer.deliver_files_deleted(@project, [@file])
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.empty?
if recipients.any?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.')
flash[:warning] = l(:warning_email_notifications, :to => to)
@ -213,7 +217,7 @@ class DmsfFilesController < ApplicationController
end
else
msg = @file.errors.full_messages.join(', ')
flash[:error] = msg
flash[:errors] = msg
Rails.logger.error msg
end
end
@ -238,7 +242,7 @@ class DmsfFilesController < ApplicationController
end
flash[:notice] = l(:notice_revision_deleted)
else
flash[:error] = @revision.errors.full_messages.join(', ')
flash[:errors] = @revision.errors.full_messages.join(', ')
end
end
redirect_to :action => 'show', :id => @file
@ -249,7 +253,7 @@ class DmsfFilesController < ApplicationController
if @revision.obsolete
flash[:notice] = l(:notice_revision_obsoleted)
else
flash[:error] = @revision.errors.full_messages.join(', ')
flash[:errors] = @revision.errors.full_messages.join(', ')
end
end
redirect_to :action => 'show', :id => @file
@ -263,7 +267,7 @@ class DmsfFilesController < ApplicationController
@file.lock!
flash[:notice] = l(:notice_file_locked)
rescue Exception => e
flash[:error] = e.message
flash[:errors] = e.message
end
end
redirect_to :back
@ -278,10 +282,10 @@ class DmsfFilesController < ApplicationController
@file.unlock!
flash[:notice] = l(:notice_file_unlocked)
rescue Exception => e
flash[:error] = e.message
flash[:errors] = e.message
end
else
flash[:error] = l(:error_only_user_that_locked_file_can_unlock_it)
flash[:errors] = l(:error_only_user_that_locked_file_can_unlock_it)
end
end
redirect_to :back
@ -311,7 +315,7 @@ class DmsfFilesController < ApplicationController
if @file.restore
flash[:notice] = l(:notice_dmsf_file_restored)
else
flash[:error] = @file.errors.full_messages.to_sentence
flash[:errors] = @file.errors.full_messages.to_sentence
end
redirect_to :back
end

View File

@ -1,7 +1,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -36,7 +36,7 @@ class DmsfFilesCopyController < ApplicationController
def copy
new_file = @file.copy_to(@target_project, @target_folder)
unless new_file.errors.empty?
flash[:error] = new_file.errors.full_messages.join(', ')
flash[:errors] = new_file.errors.full_messages.join(', ')
redirect_to :action => 'new', :id => @file, :target_project_id => @target_project,
:target_folder_id => @target_folder
return
@ -47,7 +47,7 @@ class DmsfFilesCopyController < ApplicationController
def move
unless @file.move_to(@target_project, @target_folder)
flash[:error] = @file.errors.full_messages.join(', ')
flash[:errors] = @file.errors.full_messages.join(', ')
redirect_to :action => 'new', :id => @file, :target_project_id => @target_project,
:target_folder_id => @target_folder
return
@ -89,7 +89,7 @@ private
def check_target_folder
if (@target_folder && @target_folder == @file.dmsf_folder) ||
(@target_folder.nil? && @file.dmsf_folder.nil? && @target_project == @file.project)
flash[:error] = l(:error_target_folder_same)
flash[:errors] = l(:error_target_folder_same)
redirect_to :action => :new, :id => @file, :target_project_id => @target_project.id,
:target_folder_id => @target_folder
return

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@konton.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@konton.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -20,7 +20,7 @@
class DmsfFolderPermissionsController < ApplicationController
before_action :find_folder, :only => [:destroy]
before_action :find_folder, only: [:destroy, :new, :autocomplete_for_user]
before_action :find_project
before_action :authorize
before_action :permissions
@ -49,7 +49,10 @@ class DmsfFolderPermissionsController < ApplicationController
private
def users_for_new_users
Principal.active.visible.member_of(@project).like(params[:q]).order(:type, :lastname).to_a
users = @dmsf_folder.permissions_users
ids = users.collect{ |u| u[0].id }
Principal.active.visible.member_of(@project).like(params[:q]).where(['id NOT IN (?)', ids.join(',')]).order(
:type, :lastname).to_a
end
def find_project

View File

@ -1,7 +1,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -36,7 +36,7 @@ class DmsfFoldersCopyController < ApplicationController
def copy
new_folder = @folder.copy_to(@target_project, @target_folder)
unless new_folder.errors.empty?
flash[:error] = new_folder.errors.full_messages.join(', ')
flash[:errors] = new_folder.errors.full_messages.join(', ')
redirect_to :action => 'new', :id => @folder, :target_project_id => @target_project,
:target_folder_id => @target_folder
return
@ -52,7 +52,7 @@ class DmsfFoldersCopyController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to dmsf_folder_path(:id => @target_project, :folder_id => @folder)
else
flash[:error] = @folder.errors.full_messages.join(', ')
flash[:errors] = @folder.errors.full_messages.join(', ')
redirect_to :action => 'new', :id => @folder, :target_project_id => @target_project,
:target_folder_id => @target_folder
end
@ -91,7 +91,7 @@ class DmsfFoldersCopyController < ApplicationController
def check_target_folder
if (@target_folder && @target_folder == @folder.dmsf_folder) ||
(@target_folder.nil? && @folder.dmsf_folder.nil? && @target_project == @folder.project)
flash[:error] = l(:error_target_folder_same)
flash[:errors] = l(:error_target_folder_same)
redirect_to :action => :new, :id => @folder, :target_project_id => @target_project.id,
:target_folder_id => @target_folder
return

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -112,7 +112,9 @@ class DmsfLinksController < ApplicationController
if result
flash[:notice] = l(:notice_successful_create)
else
flash[:error] = @dmsf_link.errors.full_messages.to_sentence
msg = @dmsf_link.errors.full_messages.to_sentence
flash[:errors] = msg
Rails.logger.error msg
end
else
# Link to
@ -121,12 +123,12 @@ class DmsfLinksController < ApplicationController
if params[:dmsf_link][:target_project_id].present?
@dmsf_link.project_id = params[:dmsf_link][:target_project_id]
else
project_id = DmsfFolder.find_by(id: params[:dmsf_link][:target_folder_id]).pluck(:project_id).first
unless project_id
project_ids = DmsfFolder.where(id: params[:dmsf_link][:target_folder_id]).pluck(:project_id)
unless project_ids.any?
render_404
return
end
@dmsf_link.project_id = project_id
@dmsf_link.project_id = project_ids.first
end
@dmsf_link.target_project_id = params[:dmsf_link][:project_id]
if params[:dmsf_link][:dmsf_file_id].present?
@ -141,7 +143,7 @@ class DmsfLinksController < ApplicationController
if result
flash[:notice] = l(:notice_successful_create)
else
flash[:error] = @dmsf_link.errors.full_messages.to_sentence
flash[:errors] = @dmsf_link.errors.full_messages.to_sentence
end
end
respond_to do |format|
@ -169,7 +171,7 @@ class DmsfLinksController < ApplicationController
flash[:notice] = l(:notice_successful_delete)
else
@dmsf_link.errors.each do |e, msg|
flash[:error] = msg
flash[:errors] = msg
end
end
end

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -27,7 +27,7 @@ class DmsfStateController < ApplicationController
before_action :authorize
def user_pref_save
member = @project.members.where(user_id: User.current.id).first
member = @project.members.find_by(user_id: User.current.id)
if member
member.dmsf_mail_notification = params[:email_notify]
member.dmsf_title_format = params[:title_format]
@ -35,7 +35,7 @@ class DmsfStateController < ApplicationController
if format_valid?(member.dmsf_title_format) && member.save
flash[:notice] = l(:notice_your_preferences_were_saved)
else
flash[:error] = l(:notice_your_preferences_were_not_saved)
flash[:errors] = l(:notice_your_preferences_were_not_saved)
end
else
flash[:warning] = l(:user_is_not_project_member)
@ -49,7 +49,7 @@ class DmsfStateController < ApplicationController
private
def format_valid?(format)
format.blank? || ((format =~ /%(t|d|v|i|r)/) && format.length < 256)
format.blank? || ((/%(t|d|v|i|r)/.match?(format)) && format.length < 256)
end
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -42,17 +42,17 @@ class DmsfUploadController < ApplicationController
def upload_files
uploaded_files = params[:dmsf_attachments]
@uploads = []
if uploaded_files && uploaded_files.is_a?(Hash)
if uploaded_files
# standard file input uploads
uploaded_files.each_value do |uploaded_file|
uploaded_files.each do |_, uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file)
@uploads.push(upload) if upload
end
else
# plupload multi upload completed
uploaded = params[:uploaded]
if uploaded && uploaded.is_a?(Hash)
uploaded.each_value do |uploaded_file|
if uploaded
uploaded.each do |_, uploaded_file|
@uploads.push(DmsfUpload.new(@project, @folder, uploaded_file))
end
end
@ -113,11 +113,11 @@ class DmsfUploadController < ApplicationController
def commit
@files = []
attachments = params[:attachments]
if attachments && attachments.is_a?(Hash)
if attachments
@folder = DmsfFolder.visible.find_by(id: attachments[:folder_id]) if attachments[:folder_id].present?
# standard file input uploads
uploaded_files = attachments.select { |key, value| key == 'uploaded_file'}
uploaded_files.each_value do |uploaded_file|
uploaded_files.each do |_, uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file)
if upload
uploaded_file[:disk_filename] = upload.disk_filename

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -73,15 +73,13 @@ class DmsfWorkflowsController < ApplicationController
if revision.workflow == DmsfWorkflow::STATE_APPROVED
# Just approved
recipients = DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true)
recipients.each do |user|
DmsfMailer.workflow_notification(
user,
DmsfMailer.deliver_workflow_notification(
recipients,
@dmsf_workflow,
revision,
:text_email_subject_approved,
:text_email_finished_approved,
:text_email_to_see_history).deliver if user
end
:text_email_to_see_history)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.blank?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
@ -95,16 +93,14 @@ class DmsfWorkflowsController < ApplicationController
recipients.push User.find_by(id: revision.dmsf_workflow_assigned_by)
recipients.uniq!
recipients = recipients & DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true)
recipients.each do |user|
DmsfMailer.workflow_notification(
user,
DmsfMailer.deliver_workflow_notification(
recipients,
@dmsf_workflow,
revision,
:text_email_subject_rejected,
:text_email_finished_rejected,
:text_email_to_see_history,
action.note).deliver
end
action.note)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.blank?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')
@ -118,14 +114,14 @@ class DmsfWorkflowsController < ApplicationController
# Delegation
delegate = User.find_by(id: params[:step_action].to_i / 10)
if DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(delegate)
DmsfMailer.workflow_notification(
delegate,
DmsfMailer.deliver_workflow_notification(
[delegate],
@dmsf_workflow,
revision,
:text_email_subject_delegated,
:text_email_finished_delegated,
:text_email_to_proceed,
action.note).deliver
action.note)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
flash[:warning] = l(:warning_email_notifications, :to => delegate.name)
end
@ -138,24 +134,24 @@ class DmsfWorkflowsController < ApplicationController
# Next step
assignments.each do |assignment|
if assignment.user && DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(assignment.user)
DmsfMailer.workflow_notification(
assignment.user,
DmsfMailer.deliver_workflow_notification(
[assignment.user],
@dmsf_workflow,
revision,
:text_email_subject_requires_approval,
:text_email_finished_step,
:text_email_to_proceed).deliver
:text_email_to_proceed)
end
end
to = User.find_by(id: revision.dmsf_workflow_assigned_by)
if to && DmsfMailer.get_notify_users(@project, [revision.dmsf_file], true).include?(to)
DmsfMailer.workflow_notification(
to,
DmsfMailer.deliver_workflow_notification(
[to],
@dmsf_workflow,
revision,
:text_email_subject_updated,
:text_email_finished_step_short,
:text_email_to_see_status).deliver
:text_email_to_see_status)
end
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
recipients = assignments.collect{ |a| a.user }
@ -175,7 +171,7 @@ class DmsfWorkflowsController < ApplicationController
end
flash[:notice] = l(:notice_successful_update)
elsif action.action != DmsfWorkflowStepAction::ACTION_APPROVE && action.note.blank?
flash[:error] = l(:error_empty_note)
flash[:errors] = l(:error_empty_note)
end
end
end
@ -207,12 +203,12 @@ class DmsfWorkflowsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
end
else
flash[:error] = l(:error_workflow_assign)
flash[:errors] = l(:error_workflow_assign)
end
end
end
rescue StandardError => e
flash[:error] = e.message
flash[:errors] = e.message
end
redirect_to :back
return
@ -297,7 +293,7 @@ class DmsfWorkflowsController < ApplicationController
redirect_to dmsf_workflows_path
end
else
flash[:error] = @dmsf_workflow.errors.full_messages.to_sentence
flash[:errors] = @dmsf_workflow.errors.full_messages.to_sentence
redirect_to dmsf_workflow_path(@dmsf_workflow)
end
else
@ -310,7 +306,7 @@ class DmsfWorkflowsController < ApplicationController
@dmsf_workflow.destroy
flash[:notice] = l(:notice_successful_delete)
rescue
flash[:error] = l(:error_unable_delete_dmsf_workflow)
flash[:errors] = l(:error_unable_delete_dmsf_workflow)
end
if @project
redirect_to settings_project_path(@project, :tab => 'dmsf_workflow')
@ -343,7 +339,7 @@ class DmsfWorkflowsController < ApplicationController
end
operator = (params[:commit] == l(:dmsf_and)) ? DmsfWorkflowStep::OPERATOR_AND : DmsfWorkflowStep::OPERATOR_OR
user_ids = User.where(id: params[:user_ids]).ids
if user_ids.count > 0
if user_ids.any?
user_ids.each do |user_id|
ws = DmsfWorkflowStep.new
ws.dmsf_workflow_id = @dmsf_workflow.id
@ -354,11 +350,11 @@ class DmsfWorkflowsController < ApplicationController
if ws.save
@dmsf_workflow.dmsf_workflow_steps << ws
else
flash[:error] = ws.errors.full_messages.to_sentence
flash[:errors] = ws.errors.full_messages.to_sentence
end
end
else
flash[:error] = l(:error_workflow_assign)
flash[:errors] = l(:error_workflow_assign)
end
end
respond_to do |format|
@ -376,7 +372,7 @@ class DmsfWorkflowsController < ApplicationController
if n > params[:step].to_i
ws.step = n - 1
unless ws.save
flash[:error] = l(:notice_cannot_renumber_steps)
flash[:errors] = l(:notice_cannot_renumber_steps)
end
end
end
@ -387,7 +383,7 @@ class DmsfWorkflowsController < ApplicationController
def reorder_steps
if request.put?
unless @dmsf_workflow.reorder_steps(params[:step].to_i, params[:dmsf_workflow][:position].to_i)
flash[:error] = l(:notice_cannot_renumber_steps)
flash[:errors] = l(:notice_cannot_renumber_steps)
end
end
respond_to do |format|
@ -406,7 +402,7 @@ class DmsfWorkflowsController < ApplicationController
@dmsf_workflow.notify_users(@project, revision, self)
flash[:notice] = l(:notice_workflow_started)
else
flash[:error] = l(:notice_cannot_start_workflow)
flash[:errors] = l(:notice_cannot_start_workflow)
end
end
redirect_to :back
@ -422,11 +418,11 @@ class DmsfWorkflowsController < ApplicationController
@dmsf_workflow.dmsf_workflow_steps.where(step: step.step).find_each do |s|
s.name = step.name
unless s.save
flash[:error] = s.errors.full_messages.to_sentence
flash[:errors] = s.errors.full_messages.to_sentence
end
end
else
flash[:error] = step.errors.full_messages.to_sentence
flash[:errors] = step.errors.full_messages.to_sentence
end
end
# Operators/Assignees
@ -437,7 +433,7 @@ class DmsfWorkflowsController < ApplicationController
step.operator = operator.to_i
step.user_id = params[:assignee][id]
unless step.save
flash[:error] = step.errors.full_messages.to_sentence
flash[:errors] = step.errors.full_messages.to_sentence
Rails.logger.error step.errors.full_messages.to_sentence
end
end

View File

@ -1,15 +1,35 @@
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# 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.
module DmsfFolderPermissionsHelper
def users_checkboxes(users)
s = ''
if users
users.each do |user|
content = check_box_tag('permissions[user_ids][]', user.id, true, :id => nil) + user.name
s << content_tag(:label, content, :id => "user_permission_ids_#{user.id}", :class => 'inline')
end
end
s.html_safe
end
users.each do |user|
user = [user, false] unless user.is_a?(Array)
content = check_box_tag('permissions[user_ids][]', user[0].id, true, disabled: user[1], id: nil) + user[0].name
s << content_tag(:label, content, id: "user_permission_ids_#{user[0].id}", class: 'inline')
end
s.html_safe
end
def render_principals_for_new_folder_permissions(users)
principals_check_box_tags 'user_ids[]', users

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -48,11 +48,13 @@ module DmsfHelper
# get only the filename, not the whole path
just_filename = File.basename(filename.gsub('\\\\', '/'))
# replace all non alphanumeric, hyphens or periods with underscore
just_filename = just_filename.gsub(/[^\w\.\-]/,'_')
unless just_filename =~ %r{^[a-zA-Z0-9_\.\-]*$}
just_filename.gsub!(/[^\w\.\-]/, '_')
unless %r{^[a-zA-Z0-9_\.\-]*$}.match?(just_filename)
# keep the extension if any
extension = $1 if just_filename =~ %r{(\.[a-zA-Z0-9]+)$}
just_filename = Digest::SHA256.hexdigest(just_filename) << extension
if just_filename =~ %r{(\.[a-zA-Z0-9]+)$}
extension = $1
just_filename = Digest::SHA256.hexdigest(just_filename) << extension
end
end
just_filename
end
@ -99,7 +101,7 @@ module DmsfHelper
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) &&
User.current.allowed_to?(:display_system_folders, project)
folders.reject{ |folder|
folders.reject do |folder|
if folder.system
if allowed
issue_id = folder.title.to_i
@ -115,7 +117,7 @@ module DmsfHelper
else
false
end
}
end
end
def self.all_children_sorted(parent, pos, ident)

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@lbcfree.net>
# Copyright © 2011-19 Karel Pičman <karel.picman@lbcfree.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@lbcfree.net>
# Copyright © 2011-19 Karel Pičman <karel.picman@lbcfree.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -24,9 +24,9 @@ module DmsfUploadHelper
def self.commit_files_internal(commited_files, project, folder, controller = nil)
failed_uploads = []
files = []
if commited_files && commited_files.is_a?(Hash)
if commited_files
failed_uploads = []
commited_files.each_value do |commited_file|
commited_files.each do |_, commited_file|
name = commited_file[:name]
new_revision = DmsfFileRevision.new
file = DmsfFile.visible.find_file_by_name(project, folder, name)
@ -82,8 +82,10 @@ module DmsfUploadHelper
new_revision.digest = DmsfFileRevision.create_digest commited_file[:tempfile_path]
if commited_file[:custom_field_values].present?
commited_file[:custom_field_values].each_with_index do |v, i|
new_revision.custom_field_values[i].value = v[1]
i = 0
commited_file[:custom_field_values].each do |_, v|
new_revision.custom_field_values[i].value = v
i = i + 1
end
end
@ -109,7 +111,7 @@ module DmsfUploadHelper
end
rescue Exception => e
Rails.logger.error e.message
controller.flash[:error] = e.message if controller
controller.flash[:errors] = e.message if controller
failed_uploads.push(file)
end
else
@ -140,10 +142,7 @@ module DmsfUploadHelper
# Notifications
if (folder && folder.notification?) || (!folder && project.dmsf_notification?)
begin
recipients = DmsfMailer.get_notify_users(project, files)
recipients.each do |u|
DmsfMailer.files_updated(u, project, files).deliver
end
recipients = DmsfMailer.deliver_files_updated(project, files)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.empty?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -51,7 +51,7 @@ module DmsfWorkflowsHelper
options = Array.new
options << [l(:dmsf_new_step), 0]
steps.each do |step|
options << [step.name.present? ? step.name : step.step.to_s, step.step]
options << [step.name.presence || step.step.to_s, step.step]
end
options_for_select(options, 0)
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -85,7 +85,7 @@ class DmsfFile < ActiveRecord::Base
end
end
def initialize
def initialize(*args)
@project = nil
super
end
@ -391,7 +391,7 @@ class DmsfFile < ActiveRecord::Base
next if dmsf_attrs.length == 0 || id_attribute == 0
next unless results.select{|f| f.id.to_s == id_attribute}.empty?
dmsf_file = DmsfFile.visible.where(limit_options).where(id: id_attribute).first
dmsf_file = DmsfFile.visible.where(limit_options).find_by(id: id_attribute)
if dmsf_file && DmsfFolder.permissions?(dmsf_file.dmsf_folder)
if user.allowed_to?(:view_dmsf_files, dmsf_file.project) &&
@ -417,7 +417,7 @@ class DmsfFile < ActiveRecord::Base
end
def display_name
member = Member.where(user_id: User.current.id, project_id: project_id).first
member = Member.find_by(user_id: User.current.id, project_id: project_id)
if member && !member.dmsf_title_format.nil? && !member.dmsf_title_format.empty?
title_format = member.dmsf_title_format
else

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -133,7 +133,7 @@ class DmsfFileRevision < ActiveRecord::Base
end
if Setting.plugin_redmine_dmsf['dmsf_really_delete_files']
dependencies = DmsfFileRevision.where(disk_filename: disk_filename).all.size
File.delete(disk_file) if dependencies <= 1 && File.exist?(disk_file)
FileUtils.rm_f(disk_file) if dependencies <= 1
end
super
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@konton.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@konton.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -51,17 +51,19 @@ class DmsfFolder < ActiveRecord::Base
def self.visible_condition(system=true)
Project.allowed_to_condition(User.current, :view_dmsf_folders) do |role, user|
permissions = "#{DmsfFolderPermission.table_name}"
folders = "#{DmsfFolder.table_name}"
group_ids = user.group_ids.join(',')
group_ids = -1 if group_ids.blank?
allowed = (system && role.allowed_to?(:display_system_folders)) ? 1 : 0
%{
((#{permissions}.object_id IS NULL) OR
(#{permissions}.object_id = #{role.id} AND #{permissions}.object_type = 'Role') OR
((#{permissions}.object_id = #{user.id} OR #{permissions}.object_id IN (#{group_ids})) AND #{permissions}.object_type = 'User')) AND
(#{folders}.system = #{DmsfFolder.connection.quoted_false} OR 1 = #{allowed})
}
if role.member?
permissions = "#{DmsfFolderPermission.table_name}"
folders = "#{DmsfFolder.table_name}"
group_ids = user.group_ids.join(',')
group_ids = -1 if group_ids.blank?
allowed = (system && role.allowed_to?(:display_system_folders)) ? 1 : 0
%{
((#{permissions}.object_id IS NULL) OR
(#{permissions}.object_id = #{role.id} AND #{permissions}.object_type = 'Role') OR
((#{permissions}.object_id = #{user.id} OR #{permissions}.object_id IN (#{group_ids})) AND #{permissions}.object_type = 'User')) AND
(#{folders}.system = #{DmsfFolder.connection.quoted_false} OR 1 = #{allowed})
}
end
end
end
@ -73,7 +75,7 @@ class DmsfFolder < ActiveRecord::Base
"LEFT JOIN #{DmsfFolderPermission.table_name} ON #{DmsfFolder.table_name}.id = #{DmsfFolderPermission.table_name}.dmsf_folder_id").where(
deleted: STATUS_DELETED).where(DmsfFolder.visible_condition).distinct
}
scope :system, -> { where(system: true) }
scope :issystem, -> { where(system: true) }
scope :notsystem, -> { where(system: false) }
acts_as_customizable
@ -130,9 +132,9 @@ class DmsfFolder < ActiveRecord::Base
def self.find_by_title(project, folder, title)
if folder
visible.where(project_id: project.id, dmsf_folder_id: nil, title: title).first
visible.find_by(project_id: project.id, dmsf_folder_id: nil, title: title)
else
visible.where(project_id: project.id, dmsf_folder_id: folder.id, title: title).first
visible.find_by(project_id: project.id, dmsf_folder_id: folder.id, title: title)
end
end
@ -506,8 +508,10 @@ class DmsfFolder < ActiveRecord::Base
self.dmsf_folder_id = params[:parent_id]
# Custom fields
if params[:dmsf_folder][:custom_field_values].present?
params[:dmsf_folder][:custom_field_values].each_with_index do |v, i|
custom_field_values[i].value = v[1]
i = 0
params[:dmsf_folder][:custom_field_values].each do |param|
custom_field_values[i].value = param[1]
i += 1
end
end
# Permissions
@ -541,8 +545,43 @@ class DmsfFolder < ActiveRecord::Base
title.gsub(/[#{INVALID_CHARACTERS}]/, '.').gsub(/\.{2,}/, '.').chomp('.')
end
def permission_for_role(role)
options = Hash.new
options[:checked] = false
options[:disabled] = false
permission_for_role_recursive(self, role, options)
options[:disabled] = false unless options[:checked]
options.values
end
def permissions_users
users = Array.new
permissions_users_recursive(self, users, false)
users
end
private
def permission_for_role_recursive(folder, role, options)
options[:checked] = folder.dmsf_folder_permissions.roles.exists?(object_id: role.id)
if !options[:checked] && folder.dmsf_folder && !folder.dmsf_folder.deleted?
options[:disabled] = true
# TODO: No inheritance
#permission_for_role_recursive(folder.dmsf_folder, role, options)
end
end
def permissions_users_recursive(folder, users, disabled)
if folder
usrs = Principal.active.where(id: folder.dmsf_folder_permissions.users.map{ |p| p.object_id })
usrs.each do |u|
users << [u, disabled]
end
# TODO: No inheritance
#permissions_users_recursive(folder.dmsf_folder, users, true)
end
end
def self.directory_subtree(tree, folder, level, current_folder)
folders = DmsfFolder.where(project_id: folder.project_id, dmsf_folder_id: folder.id).notsystem.visible(false).to_a
folders.delete(current_folder)

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@konton.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@konton.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -28,7 +28,9 @@ class DmsfLink < ActiveRecord::Base
belongs_to :user
validates :name, presence: true, length: { maximum: 255 }
validates :project, presence: true
# There can be project_id = -1 when attaching links to an issue. The project_id is assigned later when saving the
# issue.
#validates :project, presence: true
validates :external_url, length: { maximum: 255 }
validates :external_url, dmsf_url: true
@ -196,4 +198,4 @@ class DmsfLink < ActiveRecord::Base
csv
end
end
end

View File

@ -4,7 +4,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontorn.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontorn.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -24,33 +24,52 @@ require 'mailer'
class DmsfMailer < Mailer
layout 'mailer'
def self.deliver_files_updated(project, files)
files = files.select { |file| file.notify? }
users = get_notify_users(project, files)
users.each do |user|
files_updated(user, project, files).deliver_later
end
users
end
def files_updated(user, project, files)
if user && project && files.count > 0
files = files.select { |file| file.notify? }
if user && project && files.size > 0
redmine_headers 'Project' => project.identifier if project
@files = files
@project = project
message_id project
set_language_if_valid user.language
mail :to => user.mail,
:subject => "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_updated_subject)}"
mail :to => user.mail, subject: "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_updated_subject)}"
end
end
def self.deliver_files_deleted(project, files)
files = files.select { |file| file.notify? }
users = get_notify_users(project, files)
users.each do |user|
files_deleted(user, project, files).deliver_later
end
users
end
def files_deleted(user, project, files)
if user && files.count > 0
files = files.select { |file| file.notify? }
if user && files.any?
redmine_headers 'Project' => project.identifier if project
@files = files
@project = project
message_id project
set_language_if_valid user.language
mail :to => user.mail,
:subject => "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_deleted_subject)}"
:subject => "[#{@project.name} - #{l(:menu_dmsf)}] #{l(:text_email_doc_deleted_subject)}"
end
end
def send_documents(project, email_params)
def self.deliver_send_documents(project, email_params)
send_documents(User.current, project, email_params).deliver_later
end
def send_documents(_, project, email_params)
redmine_headers 'Project' => project.identifier if project
@body = email_params[:body]
@links_only = email_params[:links_only] == '1'
@ -63,8 +82,14 @@ class DmsfMailer < Mailer
zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read }
attachments['Documents.zip'] = { :content_type => 'application/zip', :content => zipped_content_data }
end
mail :to => email_params[:to], :cc => email_params[:cc],
:subject => email_params[:subject], 'From' => email_params[:from], 'Reply-To' => email_params[:reply_to]
mail to: email_params[:to], cc: email_params[:cc], subject: email_params[:subject], 'From' => email_params[:from],
'Reply-To' => email_params[:reply_to]
end
def self.deliver_workflow_notification(users, workflow, revision, subject_id, text1_id, text2_id, notice = nil)
users.each do |user|
workflow_notification(user, workflow, revision, subject_id.to_s, text1_id.to_s, text2_id.to_s, notice).deliver_now
end
end
def workflow_notification(user, workflow, revision, subject_id, text1_id, text2_id, notice = nil)
@ -82,7 +107,7 @@ class DmsfMailer < Mailer
@text2 = l(text2_id)
@notice = notice
mail :to => user.mail,
:subject => "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)}"
:subject => "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)}"
end
end

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -4,7 +4,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -195,15 +195,13 @@ class DmsfWorkflow < ActiveRecord::Base
recipients = assignments.collect{ |a| a.user }
recipients.uniq!
recipients = recipients & DmsfMailer.get_notify_users(project, [revision.dmsf_file], true)
recipients.each do |user|
DmsfMailer.workflow_notification(
user,
DmsfMailer.deliver_workflow_notification(
recipients,
self,
revision,
:text_email_subject_started,
:text_email_started,
:text_email_to_proceed).deliver
end
:text_email_to_proceed)
if Setting.plugin_redmine_dmsf['dmsf_display_notified_recipients']
unless recipients.blank?
to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ')

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -18,22 +18,26 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class EpmDmsfLockedDocuments < EasyPageModule
if defined?(EasyExtensions)
def category_name
@category_name ||= 'easy_dms'
end
class EpmDmsfLockedDocuments < EasyPageModule
def get_show_data(settings, user, page_context = {})
{}
end
def category_name
@category_name ||= 'easy_dms'
end
def get_edit_data(settings, user, page_context = {})
{}
end
def get_show_data(settings, user, page_context = {})
{}
end
def get_edit_data(settings, user, page_context = {})
{}
end
def registered_in_plugin
'redmine_dmsf'
end
def registered_in_plugin
'redmine_dmsf'
end
end

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -18,18 +18,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class EpmDmsfOpenApprovals < EasyPageModule
if defined?(EasyExtensions)
def category_name
@category_name ||= 'easy_dms'
end
class EpmDmsfOpenApprovals < EasyPageModule
def get_show_data(settings, user, page_context = {})
{}
end
def category_name
@category_name ||= 'easy_dms'
end
def get_show_data(settings, user, page_context = {})
{}
end
def registered_in_plugin
'redmine_dmsf'
end
def registered_in_plugin
'redmine_dmsf'
end
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -22,7 +22,7 @@
class DmsfFileNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /\A[^#{DmsfFolder::INVALID_CHARACTERS}]*\z/
unless /\A[^#{DmsfFolder::INVALID_CHARACTERS}]*\z/.match?(value)
record.errors.add attribute, :error_contains_invalid_character
end
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -25,12 +25,14 @@ class DmsfUrlValidator < ActiveModel::EachValidator
if record.target_type == 'DmsfUrl'
begin
if value.present?
URI.parse value
# https://www.google.com/search?q=寿司
URI.parse value.split('?').first
else
record.errors.add attribute, :invalid
end
rescue URI::InvalidURIError
rescue URI::InvalidURIError => e
record.errors.add attribute, :invalid
Rails.logger.error e.message
end
end
end

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -23,7 +23,7 @@
<% parent = @folder ? @folder : @project %>
<% DmsfHelper.all_children_sorted(parent, @pos, @idnt).each do |obj, position| %>
<% classes = "dmsf_tree idnt-#{@idnt} hascontextmenu" %>
<% if obj.is_a?(DmsfFolder) && ((obj.dmsf_folders.visible.count > 0) || (obj.dmsf_files.visible.count > 0) || (obj.dmsf_links.visible.count > 0)) %>
<% if obj.is_a?(DmsfFolder) && ((obj.dmsf_folders.visible.any?) || (obj.dmsf_files.visible.any?) || (obj.dmsf_links.visible.any?)) %>
<% classes += ' idnt dmsf_collapsed dmsf-not-loaded' %>
<% id = "id='#{obj.id}span'".html_safe %>
<% onclick = "onclick=\"dmsfToggle('#{obj.id}','#{obj.id}span','#{escape_javascript(expand_folder_dmsf_path)}')\"" %>

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -34,7 +34,11 @@
:target => '_blank',
:class => 'icon icon-link') %>
<div class="dmsf_filename" title="<%= l(:label_target_folder) %>">
<%= link.external_url %>
<% if link.external_url && link.external_url.length > 50 %>
<%= "#{link.external_url[0, 25]}...#{link.external_url[-25, 25]}" %>
<% else %>
<%= link.external_url %>
<% end %>
</div>
<%= '</span>'.html_safe if @tree_view %>
</td>

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -30,7 +30,13 @@
link.external_url,
:target => '_blank',
:class => 'icon icon-link') %>
<div class="dmsf_filename" title="<%= l(:label_target_folder)%>"><%= link.external_url %></div>
<div class="dmsf_filename" title="<%= l(:label_target_folder)%>">
<% if link.external_url && link.external_url.length > 50 %>
<%= "#{link.external_url[0, 25]}...#{link.external_url[-25, 25]}" %>
<% else %>
<%= link.external_url %>
<% end %>
</div>
</td>
<% end %>
<% if DmsfFolder.is_column_on?('extension') %>

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -77,12 +77,16 @@
<p>
<%= label_tag '', l(:label_permissions) %>
<% User.current.managed_roles(@project).each do |role| %>
<% checked = @folder.dmsf_folder_permissions.roles.exists?(object_id: role.id) %>
<label class="inline"><%= check_box_tag 'permissions[role_ids][]', role.id, checked, :id => nil %> <%= role %></label>
<% checked, disabled = @folder.permission_for_role(role) %>
<label class="inline">
<%= check_box_tag 'permissions[role_ids][]', role.id, checked, disabled: disabled, id: nil %>
<%= role %>
</label>
<% end %>
<span id="user_permissions">
<br/>
<% checkboxes = users_checkboxes(@users) %>
<% users = @folder.permissions_users %>
<% checkboxes = users_checkboxes(users) %>
<%= checkboxes %>
</span>
<% if checkboxes.present? %>

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -68,8 +68,13 @@
:title => l(:link_create_folder),
:class => 'icon icon-add') unless @locked_for_user %>
<% end %>
<%= link_to_if(@trash_enabled, l(:link_trash_bin), trash_dmsf_path(@project),
:title => l(:link_trash_bin), :class => 'icon icon-del') if @trash_visible %>
<% if @trash_enabled %>
<%= link_to l(:link_trash_bin), trash_dmsf_path(@project), title: l(:link_trash_bin), class: 'icon icon-del' %>
<% else %>
<span class="icon icon-del">
<%= l(:link_trash_bin) %>
</span>
<% end %>
</div>
<%= render(:partial => 'path',

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -23,17 +23,17 @@
<ul>
<li>
<%= context_menu_link l(:button_download), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
:ids => params[:ids], :download_entries => true), :method => :post, :class => 'icon-download',
:ids => params[:ids], :download_entries => true), :method => :post, :class => 'icon icon-download',
:id => 'dmsf-cm-download', :disabled => @disabled %>
</li>
<li>
<%= context_menu_link l(:field_mail), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
:ids => params[:ids], :email_entries => true), :method => :post, :class => 'icon-email',
:ids => params[:ids], :email_entries => true), :method => :post, :class => 'icon icon-email',
:disabled => @disabled %>
</li>
<li>
<%= context_menu_link l(:button_delete), entries_operations_dmsf_path(:id => @project, :folder_id => @folder,
:ids => params[:ids], :delete_entries => true), :method => :post, :class => 'icon-del',
:ids => params[:ids], :delete_entries => true), :method => :post, :class => 'icon icon-del',
:data => { :confirm => l(:text_are_you_sure) }, :id => 'dmsf-cm-delete', :disabled => @disabled %>
</li>
<% if @file %>
@ -45,7 +45,7 @@
<% end %>
<% url << @file.name %>
<% end %>
<%= context_menu_link l(:button_edit), url, :class => 'icon-edit', :disabled => url.blank? %>
<%= context_menu_link l(:button_edit), url, :class => 'icon icon-edit', :disabled => url.blank? %>
</li>
<% end %>
</ul>

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -4,12 +4,32 @@ api.dmsf_file do
api.name @file.name
api.project_id @file.project_id
api.dmsf_folder_id @file.dmsf_folder_id if @file.dmsf_folder_id
if @file.last_revision
api.version "#{@file.last_revision.version}"
api.mime_type @file.last_revision.mime_type
api.digest @file.last_revision.digest
api.size @file.last_revision.size
api.description @file.last_revision.description
end
api.content_url download_dmsf_file_url(@file)
end
api.array :dmsf_file_revisions do
@file.dmsf_file_revisions.each do |r|
api.dmsf_file_revision do
api.id r.id
api.source_dmsf_file_revision_id r.source_dmsf_file_revision_id
api.name r.name
api.dmsf_string "{{dmsf(#{@file.id},#{@file.name},#{r.id})}}"
api.content_url view_dmsf_file_url(@file, download: r)
api.size r.size
api.mime_type r.mime_type
api.title r.title
api.description r.description
api.workflow r.workflow
api.version "#{r.major_version}.#{r.minor_version}"
api.comment r.comment
api.user_id r.user_id
api.created_at r.created_at
api.updated_at r.updated_at
api.dmsf_workflow_id r.dmsf_workflow_id
api.dmsf_workflow_assigned_by r.dmsf_workflow_assigned_by
api.dmsf_workflow_assigned_at r.dmsf_workflow_assigned_at
api.dmsf_workflow_started_by r.dmsf_workflow_started_by
api.dmsf_workflow_started_at r.dmsf_workflow_started_at
api.digest r.digest
end
end
end
end

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -22,22 +22,20 @@
<h3 class="title"><%= l(:label_user_search) %></h3>
<%= form_tag(append_dmsf_folder_permissions_path,
:remote => true,
:method => :post,
:id => 'new-user-form') do %>
<%= form_tag(append_dmsf_folder_permissions_path, remote: true, method: :post, id: 'new-user-form') do %>
<%= hidden_field_tag :project_id, @project.id %>
<p><%= label_tag 'user_search', l(:label_user_search) %><%= text_field_tag 'user_search', nil %></p>
<%= late_javascript_tag "observeSearchfield('user_search', 'users_for_users', '#{ escape_javascript url_for(
:controller => 'dmsf_folder_permissions', :action => 'autocomplete_for_user', :project_id => @project) }')" %>
controller: 'dmsf_folder_permissions', action: 'autocomplete_for_user', project_id: @project,
dmsf_folder_id: @dmsf_folder) }')" %>
<div id="users_for_watcher">
<%= render_principals_for_new_folder_permissions(@principals) %>
</div>
<p class="buttons">
<%= submit_tag l(:button_add), :name => nil, :onclick => "hideModal(this);" %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
<%= submit_tag l(:button_add), name: nil, onclick: 'hideModal(this);' %>
<%= submit_tag l(:button_cancel), name: nil, onclick: 'hideModal(this);', type: 'button' %>
</p>
<% end %>

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -1,6 +1,6 @@
<%# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -4,7 +4,7 @@
# Redmine plugin for Document Management System "Features"
#
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -2,7 +2,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -5,7 +5,7 @@
#
# Copyright © 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright © 2012 Daniel Munn <dan.munn@munnster.co.uk>
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

View File

@ -3,7 +3,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright © 2011-18 Karel Pičman <karel.picman@kontron.com>
# Copyright © 2011-19 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License

Some files were not shown because too many files have changed in this diff Show More