diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b878a14ac..e974f26b4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -572,6 +572,15 @@ class AttachmentsController < ApplicationController end end + #找到文件的所有的历史版本及当前版本 + def attachment_history_download + @attachment = Attachment.find(params[:id]) + @attachment_histories = @attachment.attachment_histories + respond_to do |format| + format.js + end + end + private def find_project @attachment = Attachment.find(params[:id]) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index db81dd985..06b2df862 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -110,8 +110,7 @@ class UsersController < ApplicationController elsif @user != User.current && !User.current.admin? return render_403 end - # 初始化/更新 点击按钮时间 - # 24小时内显示系统消息 + # 初始化/更新 点击按钮时间, 24小时内显示系统消息 update_onclick_time # 全部设为已读 if params[:viewed] == "all" @@ -190,17 +189,19 @@ class UsersController < ApplicationController # 消息设置为已读 def update_message_viewed(user) - course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0) - forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0) - user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0) - forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0) - org_querys = OrgMessage.where("user_id=? and viewed=0", user) if User.current.id == @user.id - course_querys.update_all(:viewed => true) - forge_querys.update_all(:viewed => true) - user_querys.update_all(:viewed => true) - forum_querys.update_all(:viewed => true) - org_querys.update_all(:viewed => true) + course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0) + forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0) + user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0) + forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0) + org_querys = OrgMessage.where("user_id=? and viewed=0", user) + at_querys = AtMessage.where("user_id=? and viewed=0", user) + course_querys.update_all(:viewed => true) unless course_querys.nil? + forge_querys.update_all(:viewed => true) unless forge_querys.nil? + user_querys.update_all(:viewed => true) unless user_querys.nil? + forum_querys.update_all(:viewed => true) unless forum_querys.nil? + org_querys.update_all(:viewed => true) unless org_querys.nil? + at_querys.update_all(:viewed => true) unless at_querys.nil? end end @@ -823,20 +824,33 @@ class UsersController < ApplicationController user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - if(params[:type].blank? || params[:type] == "1") #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end end @type = params[:type] @limit = 7 @@ -1548,43 +1562,39 @@ class UsersController < ApplicationController user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} @user = User.find(params[:id]) - #@user.save_attachments(params[:attachments],User.current) - # Container_type为Principal + # 保存文件 attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true) + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_course_ids = User.current.courses.map { |c| c.id} + user_project_ids = User.current.projects.map {|p| p.id} + # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id], params[:order] + @attachments = get_attch_resources(params[:id], @order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources params[:id], params[:order] + @attachments = get_principal_resources(params[:id], @order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order]) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order]) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public params[:order] + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public params[:order] + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end end @status = params[:status] @@ -1604,49 +1614,44 @@ class UsersController < ApplicationController # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 def user_resource_delete if params[:resource_id].present? - Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) + Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy elsif params[:checkbox1].present? params[:checkbox1].each do |id| - Attachment.where("author_id = #{User.current.id}").delete(id) + Attachment.where("author_id =? and id =?", User.current.id, id).first.destroy end end + @user = User.current + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id], params[:order] + @attachments = get_attch_resources(params[:id], @order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources params[:id], params[:order] + @attachments = get_principal_resources(params[:id], @order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order]) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order]) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public params[:order] + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public params[:order] + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end end @status = params[:status] @@ -1669,10 +1674,10 @@ class UsersController < ApplicationController if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) - .select { |course| @user.allowed_to?(:as_teacher,course)} + .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } else @course = @user.courses - .select { |course| @user.allowed_to?(:as_teacher,course)} + .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } end @search = params[:search] #这里仅仅是传递需要发送的资源id @@ -1690,7 +1695,7 @@ class UsersController < ApplicationController search = "%#{params[:search].to_s.strip.downcase}%" @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) else - @projects = @user.projects + @projects = @user.projects.visible end @search = params[:search] #这里仅仅是传递需要发送的资源id @@ -2338,6 +2343,11 @@ class UsersController < ApplicationController attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源搜索 + def get_public_resources_search user_course_ids, user_project_ids, order, score, search + attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -2347,7 +2357,7 @@ class UsersController < ApplicationController # 获取我的资源查询结果 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) - @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2359,11 +2369,23 @@ class UsersController < ApplicationController and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") end - # 获取公共资源课程 + # 获取我的课程资源中搜索结果 + def get_course_resources_search author_id, user_course_ids, order, score, search + attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) + and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取公共资源中课程资源 def get_course_resources_public user_course_ids, order, score attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源中课程资源搜索结果 + def get_course_resources_public_search user_course_ids, order, score, search + attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我的项目资源 def get_project_resources author_id, user_project_ids, order, score attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ @@ -2371,25 +2393,55 @@ class UsersController < ApplicationController and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取我的项目资源搜索 + def get_project_resources_search author_id, user_project_ids, order, score, search + attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) + and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取公共资源的项目资源 def get_project_resources_public user_project_ids, order, score attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源的项目资源搜索 + def get_project_resources_public_search user_project_ids, order, score, search + attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我上传的附件 def get_attch_resources author_id, order, score attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', - 'Document','Message','News','StudentWorkScore','HomewCommon')) ").order("#{order.nil? ? 'created_on' : order} #{score}") + 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取我上传的附件搜索结果 + def get_attch_resources_search author_id, order, score, search + attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', + 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源中我上传的附件 def get_attch_resources_public order, score - attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') + and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取公共资源中我上传的附件 + def get_attch_resources_public_search order, score, search + attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') + and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 def get_principal_resources author_id, order, score - attchments = Attachment.where("author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取我的用户类型资源搜索 + def get_principal_resources_search author_id, order, score, search + attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 @@ -2397,6 +2449,11 @@ class UsersController < ApplicationController attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取我的用户类型资源 + def get_principal_resources_public_search order, score, search + attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 资源库 分为全部 课程资源 项目资源 附件 def user_resource @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @@ -2423,23 +2480,15 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order], @score) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order], @score) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources(params[:id], params[:order], @score) - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources(params[:id], params[:order], @score) elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids, params[:order], @score) + @attachments = get_course_resources_public( user_course_ids, @order, @score) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids, params[:order], @score) + @attachments = get_project_resources_public(user_project_ids, @order, @score) elsif params[:status] == "4" - @attachments = get_attch_resources_public(params[:order], @score) + @attachments = get_attch_resources_public(@order, @score) elsif params[:status] == "5" - @attachments = get_principal_resources_public(params[:order], @score) + @attachments = get_principal_resources_public(@order, @score) else # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) @@ -2467,16 +2516,19 @@ class UsersController < ApplicationController render_403 return end + @user = User.find(params[:id]) + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} + user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end + @status = params[:status] @type = params[:type] @limit = 10 @is_remote = true @@ -2492,26 +2544,25 @@ class UsersController < ApplicationController end def import_resources_search - search = "%#{params[:search].strip.downcase}%" + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + @user = User.current + @switch_search = params[:name].nil? ? " " : params[:name] + search = "%#{@switch_search.strip.downcase}%" # 别人的资源库是没有权限去看的 if User.current.id.to_i != params[:id].to_i render_403 return end - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} desc") + @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search) elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end @type = params[:type] @limit = 10 @@ -2520,10 +2571,10 @@ class UsersController < ApplicationController @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments, 10 respond_to do |format| format.js - format.html {render :layout => 'new_base'} + # format.html {render :layout => 'new_base'} end end @@ -2584,69 +2635,39 @@ class UsersController < ApplicationController @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc" @score = @b_sort == "desc" ? "asc" : "desc" @user = User.current - switch_search = params[:search].nil? ? " " : params[:search] - search = "%#{switch_search.strip.downcase}%" - user_course_ids = User.current.courses.map { |c| c.id} + @switch_search = params[:search].nil? ? " " : params[:search] + search = "%#{@switch_search.strip.downcase}%" + user_course_ids = User.current.courses.map {|c| c.id} user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部 if params[:status] == "2" - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search) elsif params[:status] == "3" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_project_resources_search(params[:id], user_project_ids, @order, @score, search) elsif params[:status] == "4" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_attch_resources_search(params[:id], @order, @score, search) elsif params[:status] == "5" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_principal_resources_search(params[:id], @order, @score, search) else # 公共资源库:所有公开资源或者我上传的私有资源 - get_my_resources_search(@user.id, user_course_ids, user_project_ids, @order, @score, search) - end - elsif params[:type] == "2" #课程资源 - if User.current.id.to_i == params[:id].to_i - user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ - " and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "3" # 项目资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "4" # 附件 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search) end - elsif params[:type] == "5" # 用户资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "6" # 全部资源 + elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_course_resources_public_search(user_course_ids, @order, @score, search) elsif params[:status] == "3" - @attachments = Attachment.where("container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_project_resources_public_search(user_project_ids, @order, @score, search) elsif params[:status] == "4" - @attachments = Attachment.where("container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_attch_resources_public_search(@order, @score, search) elsif params[:status] == "5" - @attachments = Attachment.where("container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_principal_resources_public_search(@order, @score, search) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("created_on desc") + @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end end @status = params[:status] @type = params[:type] - @type = params[:type] @limit = 25 @is_remote = true @atta_count = @attachments.count diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1cc0d3b7a..714da9920 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,8 +90,8 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_save :act_as_course_activity - after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index + after_save :act_as_course_activity,:act_as_forge_activity + after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score @@ -606,7 +606,7 @@ class Attachment < ActiveRecord::Base # Author lizanle # Description 上传该项目的文档资料也要保存一份在公共表中 def act_as_forge_activity - if self.container_type == 'Project' + if self.container_type == 'Project' && self.forge_acts.empty? self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.container_id) end diff --git a/app/views/attachments/_attachment_history_download.html.erb b/app/views/attachments/_attachment_history_download.html.erb new file mode 100644 index 000000000..c805960f0 --- /dev/null +++ b/app/views/attachments/_attachment_history_download.html.erb @@ -0,0 +1,30 @@ + +选择版本 +

注:该文件有历史版本,请选择您需要的文件,点击文件名下载。

+

版本及序号

+ +
+ + <%= link_to truncate(@attachment.filename,length: 35, omission: '...'), + download_named_attachment_path(@attachment.id, @attachment.filename), + :title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> + + 版本号:当前 +
+ <% @attachment_histories.each do |history| %> + + <%= link_to truncate(history.filename,length: 35, omission: '...'), + download_history_attachment_path(history.id, history.filename), + :title => history.filename+"\n"+history.description.to_s, + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> + + 版本号:<%= history.version %> +
+ <% end %> +
diff --git a/app/views/attachments/attachment_history_download.js.erb b/app/views/attachments/attachment_history_download.js.erb new file mode 100644 index 000000000..352a2ef93 --- /dev/null +++ b/app/views/attachments/attachment_history_download.js.erb @@ -0,0 +1,7 @@ +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>'); +showModal('ajax-modal', '452px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","40%").css("left","50%"); +$('#ajax-modal').parent().addClass("resourceUploadPopup"); +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 90ae3516d..b839128da 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -9,9 +9,17 @@
- <%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'), - download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index a2a1670d1..2ee726d77 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -8,9 +8,17 @@
- <%= link_to truncate(file.filename,length: 35, omission: '...'), - download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 317bb7dd8..20ffb1e50 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -6,9 +6,17 @@
- <%= link_to truncate(file.filename,length: 35, omission: '...'), - download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> @@ -38,31 +46,28 @@ <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
-
  • <% if User.current.logged? %> - <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
      -
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
    • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
    • <% if @course.is_public? %>
    • - - <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> - + + <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> +
    • <%end%>
    • <%= link_to( '删除资源', attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
    - <% end %> <%else%>
      diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 8ab1851e4..315b1d300 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -109,7 +109,7 @@
    diff --git a/app/views/users/_import_resource_info.html.erb b/app/views/users/_import_resource_info.html.erb index bc1152ce4..4ea56ad9f 100644 --- a/app/views/users/_import_resource_info.html.erb +++ b/app/views/users/_import_resource_info.html.erb @@ -26,11 +26,14 @@ 公共资源 我的资源 <% end %> - <%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id, :type => 1), - :remote => true , :method => 'get', :id => 'resource_search_form') do %> + + - <%#= hidden_field_tag(:type,type.nil? ? 1 : type) %> - <%# end %> + + +
    @@ -42,25 +45,10 @@
  • 上传者
  • 上传时间
- <%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', - :mul_id => params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id], - :mul_type => params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"}), - :method => 'post', :id => 'resource_import_container_form') do %> - <% @attachments.each do |attach| %> -
    - -
  • <%= get_resource_type(attach.container_type)%>
  • - -
  • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
  • -
  • <%= format_date(attach.created_on) %>
  • -
- <% end %> - <% end %> +
+ <%= render :partial => 'users/user_import_resource_list',:locals => {:project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} %> +
+
diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index f679f9c8c..a545038f1 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -16,7 +16,7 @@
  • <%= attach.quotes.nil? ? 0 : attach.quotes %>
  • <%= attach.downloads %>
  • <%= attach.author_id %>
  • -
  • <%= number_to_human_size(attach.filesize) %>
  • +
  • <%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %>
  • <%= get_resource_type(attach.container_type)%>
  • diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb new file mode 100644 index 000000000..af4f951e0 --- /dev/null +++ b/app/views/users/_user_import_resource_list.html.erb @@ -0,0 +1,19 @@ +<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', + :mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id, + :mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}), + :method => 'post', :id => 'resource_import_container_form') do %> + <% @attachments.each do |attach| %> +
      + +
    • <%= get_resource_type(attach.container_type)%>
    • + +
    • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
    • +
    • <%= format_date(attach.created_on) %>
    • +
    + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/users/_user_import_resource_search.html.erb b/app/views/users/_user_import_resource_search.html.erb new file mode 100644 index 000000000..b048675dd --- /dev/null +++ b/app/views/users/_user_import_resource_search.html.erb @@ -0,0 +1,29 @@ + + \ No newline at end of file diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb index 6bc169f21..ce821bd4f 100644 --- a/app/views/users/_user_message_userfeedaback.html.erb +++ b/app/views/users/_user_message_userfeedaback.html.erb @@ -1,30 +1,30 @@ -<% if ma.class == UserFeedbackMessage %> - <% if ma.journals_for_message_type == "JournalsForMessage" %> -
      -
    • - <%=link_to image_tag(url_to_avatar(ma.journals_for_message.user), :width => "30", :height => "30"), user_path(ma.journals_for_message.user) %> -
    • -
    • - <%=link_to ma.journals_for_message.user, user_path(ma.journals_for_message.user), :class => "newsBlue homepageNewsPublisher" %> - "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %> -
    • -
    • - <%= link_to ma.journals_for_message.notes.gsub("

      ","").gsub("

      ","").gsub("
      ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> -
    • - -
    • <%= time_tag(ma.journals_for_message.created_on).html_safe %>
    • - -
    - <% end %> +<% if ma.class == UserFeedbackMessage %> + <% if ma.journals_for_message_type == "JournalsForMessage" %> +
      +
    • + <%=link_to image_tag(url_to_avatar(ma.journals_for_message.user), :width => "30", :height => "30"), user_path(ma.journals_for_message.user) %> +
    • +
    • + <%=link_to ma.journals_for_message.user, user_path(ma.journals_for_message.user), :class => "newsBlue homepageNewsPublisher" %> + "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %> +
    • +
    • + <%= link_to ma.journals_for_message.notes.gsub("

      ","").gsub("

      ","").gsub("
      ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
    • + +
    • <%= time_tag(ma.journals_for_message.created_on).html_safe %>
    • + +
    + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_resource_type_filter.html.erb b/app/views/users/_user_resource_type_filter.html.erb index 9a1fad552..6e5ed51c3 100644 --- a/app/views/users/_user_resource_type_filter.html.erb +++ b/app/views/users/_user_resource_type_filter.html.erb @@ -2,24 +2,24 @@
    • - 全部 + 全部
    • - 课程资源 + 课程资源 <%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %>
    • - 项目资源 + 项目资源 <%#= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), id="resource_type_project", :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %>
    • - 用户资源 + 用户资源 <%#= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5), id="resource_type_user", :remote=>true,:method => 'get', :class=>'resourcesTypeUser resourcesGrey' %>
    • <% if @type != "6" %>
    • - 附件 + 附件 <%#= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4), id="resource_type_file", :remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
    • <% end %> diff --git a/app/views/users/import_resources_search.js.erb b/app/views/users/import_resources_search.js.erb index 549cf6329..ea527ab6b 100644 --- a/app/views/users/import_resources_search.js.erb +++ b/app/views/users/import_resources_search.js.erb @@ -1,25 +1,3 @@ -//$("#resources_list").html('<%#= escape_javascript( render :partial => 'users/import_resource_info' ,:locals=>{ :attachments => @attachments, :type => @type})%>'); -//$("#pages").html('<%#= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -//$("#res_all_count").html(<%#= @atta_count%>); -//$("#res_count").html(0); -//$("#checkboxAll").attr('checked',false); - - -<% if params[:project_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :project_id => params[:project_id]} ) %>'); -<% elsif params[:course_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :course_id => params[:course_id]} ) %>'); -<% elsif params[:subfield_file_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :subfield_file_id => params[:subfield_file_id]} ) %>'); -<% end %> -showModal('ajax-modal', '615px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -<% if params[:project_id] %> -$('#ajax-modal').parent().css("top","10%").css("left","34%").css("border","3px solid #269ac9"); -<% else %> -$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9"); -<% end %> -$('#ajax-modal').parent().addClass("popbox_polls"); - - +$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list', + :locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 38e80e75b..9583274c6 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -5,10 +5,10 @@ $("#res_all_count").html(<%= @atta_count%>); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); //更新状态 -$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6', :status => @status) %>'); -$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1', :status => @status) %>'); -$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1) %>'); -$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2) %>'); -$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3) %>'); -$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5) %>'); -$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4) %>'); \ No newline at end of file +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index cfaa0228c..80167db56 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -1,12 +1,8 @@ -<%= javascript_include_tag 'bootstrap'%> +<%= javascript_include_tag 'bootstrap' %> <%= stylesheet_link_tag 'project' %> <%= stylesheet_link_tag 'leftside' %> -<%= javascript_include_tag 'attachments'%> - - - - - +<%= javascript_include_tag 'attachments' %> +