As target projects only those projects with DMSF module enabled

This commit is contained in:
Karel Picman 2017-02-16 13:46:20 +01:00
parent d4d5e78fd8
commit 29e89f9692
2 changed files with 9 additions and 3 deletions

View File

@ -237,7 +237,10 @@ class DmsfFile < ActiveRecord::Base
if User.current.admin?
projects = Project.visible.has_module('dmsf').all
elsif User.current.logged?
User.current.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:file_manipulation)} && m.project.module_enabled?('dmsf')}
User.current.memberships.each do |m|
projects << m.project if m.project.module_enabled?('dmsf') &&
m.roles.detect { |r| r.allowed_to?(:file_manipulation) }
end
end
projects
end

View File

@ -217,9 +217,12 @@ class DmsfFolder < ActiveRecord::Base
def self.allowed_target_projects_on_copy
projects = []
if User.current.admin?
projects = Project.visible.all
projects = Project.visible.has_module('dmsf').all
elsif User.current.logged?
User.current.memberships.each {|m| projects << m.project if m.roles.detect {|r| r.allowed_to?(:folder_manipulation) && r.allowed_to?(:file_manipulation)}}
User.current.memberships.each do |m|
projects << m.project if m.project.module_enabled?('dmsf') &&
m.roles.detect { |r| r.allowed_to?(:folder_manipulation) && r.allowed_to?(:file_manipulation) }
end
end
projects
end