From 929da7512da5d1c17d8e913b7e7937424faabead Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 19 Aug 2015 17:13:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 33 ++++++++- .../users/_resource_search_form.html.erb | 2 +- .../users/_resource_share_popup.html.erb | 15 +++- app/views/users/_resources_list.html.erb | 5 +- app/views/users/user_resource.html.erb | 58 +++++++++------- public/stylesheets/images/homepage_icon.png | Bin 0 -> 6829 bytes public/stylesheets/images/nav_icon.png | Bin 0 -> 3204 bytes public/stylesheets/public_new.css | 65 ++++++++++++++---- 8 files changed, 133 insertions(+), 45 deletions(-) create mode 100644 public/stylesheets/images/homepage_icon.png create mode 100644 public/stylesheets/images/nav_icon.png diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c523bbb3d..e4109e5bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -825,7 +825,38 @@ class UsersController < ApplicationController # 删除用户资源 def user_resource_delete Attachment.delete(params[:resource_id]) - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + #@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + 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 in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") + 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.join(',')}))").order("created_on desc") + 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'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") + 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')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + end + end + @type = params[:type] respond_to do |format| format.js end diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index 725167b65..5f854cba0 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -2,6 +2,6 @@ :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> <%= hidden_field_tag(:type,type) %> - <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> + <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %> <% end %> \ No newline at end of file diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index 01ac79075..cad94056c 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -1,8 +1,17 @@ -