diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index e83a13ad9..ca37e445c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,7 +26,7 @@ class FilesController < ApplicationController before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project, :search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment, :search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache, - :search_files_in_subfield,:upload_files_menu] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file] helper :sort include SortHelper @@ -96,6 +96,33 @@ class FilesController < ApplicationController end end + def file_hidden + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + respond_to do |format| + format.js + end + end + + def republish_file + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + if params[:publish_time] + unless params[:publish_time] == "" + @file.publish_time = params[:publish_time] + end + end + if @file.publish_time > Date.today + @file.is_publish = 0 + else + @file.is_publish = 1 + end + @file.save + respond_to do |format| + format.js + end + end + def search_project sort = "" @sort = "" diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index bae0232a5..2a4bcf9c8 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -30,7 +30,8 @@ class OrgSubfieldsController < ApplicationController if params[:id] @organization = Organization.find(params[:id]) else - @organization = Organization.where("domain=?",request.subdomain).first + domain = Secdomain.where("subname=?", request.subdomain).first + @organization = Organization.find(domain.pid) end @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6e2da311f..f225e7f50 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -139,7 +139,7 @@ class OrganizationsController < ApplicationController end def check_uniq_domain - @is_exist = (Organization.where("domain=?", params[:org_domain]).count > 0) + @is_exist = (Secdomain.where("subname=?",params[:org_domain]).count > 0) end def find_organization @@ -322,7 +322,12 @@ class OrganizationsController < ApplicationController def agree_apply_subdomain @organization = Organization.find(params[:organization_id]) OrgMessage.find(params[:act_id]).update_attribute(:viewed, 1) - @organization.update_attribute(:domain, params[:org_domain]) + if Secdomain.where("pid=? and sub_type=2",@organization.id).count > 0 + domain = Secdomain.where("pid=? and sub_type=2",params[:organization_id]).first + Secdomain.update(domain.id, :subname => params[:org_domain]) + else + Secdomain.create(:sub_type => 2, :pid => params[:organization_id], :subname => params[:org_domain]) + end if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=?",params[:org_domain]).count == 0 OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain]) end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index e6ff904f3..7ccb3177c 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1055,4 +1055,4 @@ class StudentWorkController < ApplicationController end end end -end \ No newline at end of file +end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index d66c6a30d..386e5733d 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -134,8 +134,11 @@ class ZipdownController < ApplicationController homework_common.student_works.each do |work| unless work.attachments.empty? out_file = zip_student_work_by_user(work) - bid_homework_path << out_file.file_path - digests << out_file.file_digest + + bid_homework_path << out_file.file_path + digests << out_file.file_digest + + end end homework_id = homework_common.id @@ -172,7 +175,11 @@ class ZipdownController < ApplicationController } end - def zip_student_work_by_user work + def make_zip_name(work) + "#{work.user.show_name}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}" + end + + def zip_student_work_by_user(work) homeworks_attach_path = [] not_exist_file = [] # 需要将所有homework.attachments遍历加入zip @@ -186,10 +193,23 @@ class ZipdownController < ApplicationController digests << 'not_exist_file' end end - out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - zipping("#{work.user.show_name}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", - homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) - } + + #单个文件的话,不需要压缩,只改名 + out_file = nil + if homeworks_attach_path.size == 1 + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}" + FileUtils.cp homeworks_attach_path.first, des_path + des_path + } + else + out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ + zipping("#{make_zip_name(work)}.zip", + homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) + } + end + out_file + end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 6d0066fbc..2cdb277be 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -746,7 +746,7 @@ module CoursesHelper return[] unless course result = [] course.attachments.each do |attachment| - if attachment.is_public? ||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? ||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? result << attachment end end diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb index 292587cad..e222d8e56 100644 --- a/app/views/blog_comments/_simple_ke_reply_form.html.erb +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -1,16 +1,3 @@ - -
文件大小:<%= number_to_human_size(file.filesize) %>
+下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+域名目录(用户自定义url,可选)
- <% if @organization.domain %> - <%= @organization.domain %>.trustie.net/ + <% if domain %> + <%= domain.subname %>.trustie.net/ <% else %> 您还没有子域名,请先在左侧信息栏申请子域名 <% end %> diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index 062d64096..c036633a5 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -35,18 +35,7 @@ }) }) - + <% unless forge_acts.empty? %> <% forge_acts.each do |activity| -%> - + <% user_activities.each do |user_activity| if user_activities %>