From 96e02cd48f6d3c0405e3f24b5c9084a4fc2b2425 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Dec 2016 17:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=A4=BE=E5=8C=BA=E3=80=81?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=A4=BE=E5=8C=BA=E7=82=B9=E5=87=BB=E6=88=91?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81=E9=94=99=E8=AF=AF=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E7=94=A8=E6=88=B7=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 22 ++++++++++++++++--- .../layouts/base_project_community.html.erb | 5 ----- app/views/users/course_community.html.erb | 2 +- app/views/users/project_community.html.erb | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c5d5962b2..314f63069 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1825,7 +1825,11 @@ class UsersController < ApplicationController messages.each do |message_all| mess = message_all.message unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) - @message_alls << mess + if (message_all.message_type =="SystemMessage" && !many_days_ago(mess.created_at, 30)) + next + else + @message_alls << mess + end end end @message_count = @message_alls.count @@ -2135,6 +2139,9 @@ class UsersController < ApplicationController when "course_journals" container_type = 'Course' act_type = 'JournalsForMessage' + when "current_user" + container_type = 'Principal' + act_type = 'Principal' when "all" container_type = 'all' act_type = 'all' @@ -2143,12 +2150,15 @@ class UsersController < ApplicationController if container_type != '' && container_type != 'all' if container_type == 'Course' sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'" + elsif container_type == 'Principal' && act_type == 'Principal' + sql = "user_id = #{@user.id} and (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" end if User.current != @user sql += " and user_id = #{@user.id}" end else - sql = "(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" + sql = "(container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})" + + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " if container_type != 'all' && User.current != @user sql = "user_id = #{@user.id} and(" + sql + ")" end @@ -2181,6 +2191,9 @@ class UsersController < ApplicationController when "project_message" container_type = 'Project' act_type = 'Message' + when "current_user" + container_type = 'Principal' + act_type = 'Principal' when "all" container_type = 'all' act_type = 'all' @@ -2189,12 +2202,15 @@ class UsersController < ApplicationController if container_type != '' && container_type != 'all' if container_type == 'Project' sql = "container_type = '#{container_type}' and container_id in #{user_project_ids} and act_type = '#{act_type}'" + elsif container_type == 'Principal' && act_type == 'Principal' + sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}))" end if User.current != @user sql += " and user_id = #{@user.id}" end else - sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " if container_type != 'all' && User.current != @user sql = "user_id = #{@user.id} and(" + sql + ")" end diff --git a/app/views/layouts/base_project_community.html.erb b/app/views/layouts/base_project_community.html.erb index e61bd67cf..ee8ed23db 100644 --- a/app/views/layouts/base_project_community.html.erb +++ b/app/views/layouts/base_project_community.html.erb @@ -66,11 +66,6 @@ <% end %> - <%# 更新访问数,刷新的时候更新访问次数 %> <% update_visiti_count @user %> diff --git a/app/views/users/course_community.html.erb b/app/views/users/course_community.html.erb index 724bb730c..c31e5aa64 100644 --- a/app/views/users/course_community.html.erb +++ b/app/views/users/course_community.html.erb @@ -15,7 +15,7 @@
  • <%= link_to "论坛动态", {:controller => "users", :action => "course_community", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey" %>
  • <%= link_to "问卷动态", {:controller => "users", :action => "course_community", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %>
  • <%= link_to "班级留言", {:controller => "users", :action => "course_community", :type => "course_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
  • -
  • <%= link_to "个人留言", {:controller => "users", :action => "course_community", :type => "user_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
  • + <% end %> diff --git a/app/views/users/project_community.html.erb b/app/views/users/project_community.html.erb index 64ce8ce9e..36b8591b5 100644 --- a/app/views/users/project_community.html.erb +++ b/app/views/users/project_community.html.erb @@ -13,7 +13,7 @@ :class => "homepagePostTypeMine postTypeGrey" %>
  • <%= link_to "问题动态", {:controller => "users", :action => "project_community", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%>
  • <%= link_to "论坛动态", {:controller => "users", :action => "project_community", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
  • -
  • <%= link_to "个人留言", {:controller => "users", :action => "project_community", :type => "user_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
  • + <% end %>