From fa0147952213c917617dddc8aa729cd0ca436ecf Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Thu, 22 Jun 2017 18:42:29 +0200 Subject: [PATCH] Postgres compatibility --- app/models/dmsf_folder.rb | 12 ++++++------ lib/redmine_dmsf/patches/issue_patch.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 79cdcc71..d977ad4d 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -90,14 +90,14 @@ class DmsfFolder < ActiveRecord::Base if user.id && user.logged? permissions = "#{DmsfFolderPermission.table_name}" folders = "#{DmsfFolder.table_name}" - group_ids = user.groups.map{ |g| g.id }.join(',') + 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 = 0 OR 1 = #{allowed}) + (#{folders}.system = #{DmsfFolder.connection.quoted_false} OR 1 = #{allowed}) } else '0 = 1' @@ -459,22 +459,22 @@ class DmsfFolder < ActiveRecord::Base end def save(*args) - RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) + RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) super(*args) end def save!(*args) - RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) + RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) super(*args) end def destroy - RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) + RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) super end def destroy! - RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) + RedmineDmsf::Webdav::Cache.invalidate_item(propfind_cache_key) super end diff --git a/lib/redmine_dmsf/patches/issue_patch.rb b/lib/redmine_dmsf/patches/issue_patch.rb index 6578e1d0..78845102 100644 --- a/lib/redmine_dmsf/patches/issue_patch.rb +++ b/lib/redmine_dmsf/patches/issue_patch.rb @@ -106,7 +106,7 @@ module RedmineDmsf parent.save end if parent - folder = DmsfFolder.system.where(['project_id = ? AND dmsf_folder_id = ? AND CAST(title AS UNSIGNED) = ?', + folder = DmsfFolder.system.where(['project_id = ? AND dmsf_folder_id = ? AND CAST(title AS DECIMAL) = ?', self.project_id, parent.id, self.id]).first if create && !folder folder = DmsfFolder.new