|
|
|
@ -36,7 +36,7 @@ class UsersController < ApplicationController
|
|
|
|
|
#
|
|
|
|
|
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
|
|
|
|
|
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks,
|
|
|
|
|
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
|
|
|
|
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :update_message_viewed,
|
|
|
|
|
:anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks,
|
|
|
|
|
:unapproval_applied_list, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
|
|
|
|
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues,
|
|
|
|
@ -489,9 +489,9 @@ class UsersController < ApplicationController
|
|
|
|
|
# 初始化/更新 点击按钮时间, 24小时内显示系统消息
|
|
|
|
|
update_onclick_time
|
|
|
|
|
# 全部设为已读
|
|
|
|
|
if params[:viewed] == "all"
|
|
|
|
|
update_message_viewed(@user)
|
|
|
|
|
end
|
|
|
|
|
# if params[:viewed] == "all"
|
|
|
|
|
# update_message_viewed(@user)
|
|
|
|
|
# end
|
|
|
|
|
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
|
|
|
|
courses = @user.courses.where("is_delete = 1")
|
|
|
|
|
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
|
|
|
|
@ -571,27 +571,28 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 消息设置为已读
|
|
|
|
|
def update_message_viewed(user)
|
|
|
|
|
def update_message_viewed
|
|
|
|
|
if User.current.id == @user.id
|
|
|
|
|
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)
|
|
|
|
|
contest_querys = ContestMessage.where(:user_id => user, :viewed => 0)
|
|
|
|
|
blog_querys = BlogMessage.where(:user_id => user, :viewed => 0)
|
|
|
|
|
applied_querys = AppliedMessage.where("user_id=? and viewed =?", user, 0)
|
|
|
|
|
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?
|
|
|
|
|
contest_querys.update_all(:viewed => true) unless contest_querys.nil?
|
|
|
|
|
blog_querys.update_all(:viewed => true) unless blog_querys.nil?
|
|
|
|
|
applied_querys.update_all(:viewed => true) unless applied_querys.nil?
|
|
|
|
|
course_querys = CourseMessage.where("user_id =? and viewed =?", @user.id, 0)
|
|
|
|
|
forge_querys = ForgeMessage.where("user_id =? and viewed =?", @user.id, 0)
|
|
|
|
|
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", @user.id, 0)
|
|
|
|
|
forum_querys = MemoMessage.where("user_id =? and viewed =?", @user.id, 0)
|
|
|
|
|
org_querys = OrgMessage.where("user_id=? and viewed=0", @user.id)
|
|
|
|
|
at_querys = AtMessage.where("user_id=? and viewed=0", @user.id)
|
|
|
|
|
contest_querys = ContestMessage.where(:user_id => @user.id, :viewed => 0)
|
|
|
|
|
blog_querys = BlogMessage.where(:user_id => @user.id, :viewed => 0)
|
|
|
|
|
applied_querys = AppliedMessage.where("user_id=? and viewed =?", @user.id, 0)
|
|
|
|
|
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?
|
|
|
|
|
contest_querys.update_all(:viewed => true) unless contest_querys.nil?
|
|
|
|
|
blog_querys.update_all(:viewed => true) unless blog_querys.nil?
|
|
|
|
|
applied_querys.update_all(:viewed => true) unless applied_querys.nil?
|
|
|
|
|
end
|
|
|
|
|
redirect_to user_path(@user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 系统消息
|
|
|
|
@ -2011,9 +2012,6 @@ class UsersController < ApplicationController
|
|
|
|
|
def show
|
|
|
|
|
if User.current == @user
|
|
|
|
|
# 全部设为已读
|
|
|
|
|
if params[:viewed] == "set_viewed"
|
|
|
|
|
update_message_viewed(@user)
|
|
|
|
|
end
|
|
|
|
|
# 自己的主页显示消息
|
|
|
|
|
messages_all = MessageAll.where(:user_id => @user.id)
|
|
|
|
|
@message_count = messages_all.count
|
|
|
|
|