修改游客下载组织资源的权限

ouyang
ouyangxuhua 10 years ago
parent f496761325
commit a7312a6191

@ -2023,7 +2023,7 @@ module ApplicationHelper
candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1) candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1)
elsif attachment_history.container_type == "OrgSubfield" elsif attachment_history.container_type == "OrgSubfield"
org = OrgSubfield.find(attachment_history.container_id) org = OrgSubfield.find(attachment_history.container_id)
candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1) candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1 && (User.current.logged? || org.organization.allow_guest_download?))
end end
end end

@ -822,6 +822,9 @@ class User < Principal
end end
def member_of_org?(org) def member_of_org?(org)
if !self.logged?
return false
end
OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0
end end

@ -3,7 +3,7 @@ class SetPriorityForOrgSubfields < ActiveRecord::Migration
Organization.all.each do |org| Organization.all.each do |org|
org.transaction do org.transaction do
org.org_subfields.where("field_type='default'").each do|field| org.org_subfields.where("field_type='default'").each do|field|
case field.field_type case field.name
when 'activity' when 'activity'
field.update_attribute(:priority, 1) field.update_attribute(:priority, 1)
when 'course' when 'course'

Loading…
Cancel
Save