From ef5625ccdf614a07bc86a85cb21503b18b136af6 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 11 Mar 2016 11:17:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E6=9C=9F=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E8=AE=BE=E4=B8=BA=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E5=90=8E=E4=B8=8D=E5=BA=94=E5=AF=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=8F=AF=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- app/helpers/files_helper.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 148b20d2e..3989ad724 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -780,7 +780,7 @@ module CoursesHelper return[] unless course result = [] course.attachments.each do |attachment| - if attachment.is_public? ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? + if (attachment.is_public? && attachment.is_publish == 1) ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,course)|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? result << attachment end end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 238999a71..913c49310 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -121,7 +121,8 @@ module FilesHelper def visable_attachemnts attachments result = [] attachments.each do |attachment| - if attachment.is_public? || + if (attachment.is_public? && attachment.container_type != "Course") || + (attachment.is_public? && attachment.container_type == "Course" && attachment.is_publish == 1)|| (attachment.container_type == "Project" && User.current.member_of?(attachment.project)) || (attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))|| (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||