Merge branch 'szzh' into develop
This commit is contained in:
commit
c23976354b
|
@ -89,72 +89,54 @@ class MessagesController < ApplicationController
|
|||
|
||||
# Create a new topic
|
||||
def new
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
# # 与我相关动态的记录add start
|
||||
# if(@board && @board.course) #项目的先不管
|
||||
# teachers = searchTeacherAndAssistant(@board.course)
|
||||
# for teacher in teachers
|
||||
# if(teacher.user_id != User.current.id)
|
||||
# notify = ActivityNotify.new()
|
||||
# if(@board.course)
|
||||
# notify.activity_container_id = @board.course_id
|
||||
# notify.activity_container_type = 'Course'
|
||||
# else
|
||||
# notify.activity_container_id = @board.project_id
|
||||
# notify.activity_container_type = 'Project'
|
||||
# end
|
||||
# notify.activity_id = @message.id
|
||||
# notify.activity_type = 'Message'
|
||||
# notify.notify_to = teacher.user_id
|
||||
# notify.is_read = 0
|
||||
# notify.save()
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# 与我相关动态的记录add end
|
||||
if User.current.logged?
|
||||
@message = Message.new
|
||||
@message.author = User.current
|
||||
@message.board = @board
|
||||
@message.safe_attributes = params[:message]
|
||||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course)
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course)
|
||||
end
|
||||
else
|
||||
redirect_to board_message_url(@board, @message)
|
||||
end
|
||||
else
|
||||
redirect_to board_message_url(@board, @message)
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project, :flag => true)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course, :flag => true)
|
||||
end
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
if params[:is_board]
|
||||
if @project
|
||||
redirect_to project_boards_path(@project, :flag => true)
|
||||
elsif @course
|
||||
redirect_to course_boards_path(@course, :flag => true)
|
||||
end
|
||||
else
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :action => 'new', :layout => layout_file
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
layout_file = @project ? 'base_projects' : 'base_courses'
|
||||
render :layout => layout_file
|
||||
}
|
||||
end
|
||||
redirect_to signin_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -102,22 +102,22 @@ class UsersController < ApplicationController
|
|||
# issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment)
|
||||
def user_messages
|
||||
unless User.current.logged?
|
||||
render_403
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
# 当前用户查看消息,则设置消息为已读
|
||||
#if params[:viewed] == "all"
|
||||
# course_querys = @user.course_messages
|
||||
# forge_querys = @user.forge_messages
|
||||
# user_querys = @user.user_feedback_messages
|
||||
# forum_querys = @user.memo_messages
|
||||
# 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)
|
||||
# end
|
||||
#end
|
||||
if params[:viewed] == "all"
|
||||
course_querys = @user.course_messages
|
||||
forge_querys = @user.forge_messages
|
||||
user_querys = @user.user_feedback_messages
|
||||
forum_querys = @user.memo_messages
|
||||
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)
|
||||
end
|
||||
end
|
||||
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
||||
case params[:type]
|
||||
when nil
|
||||
|
@ -553,6 +553,10 @@ class UsersController < ApplicationController
|
|||
|
||||
# modified by fq
|
||||
def user_newfeedback
|
||||
unless User.current.logged?
|
||||
redirect_to signin_url
|
||||
return
|
||||
end
|
||||
# 更新用户留言消息状态
|
||||
@user.journals_for_messages.each do |jour_message|
|
||||
jour_message.user_feedback_messages.each do |userfeedback_message|
|
||||
|
|
|
@ -202,11 +202,15 @@ class WordsController < ApplicationController
|
|||
|
||||
#给用户留言
|
||||
def leave_user_message
|
||||
@user = User.find(params[:id])
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
|
||||
@user.add_jour(User.current, params[:new_form][:user_message])
|
||||
if User.current.logged?
|
||||
@user = User.find(params[:id])
|
||||
if params[:new_form][:user_message].size>0 && User.current.logged? && @user
|
||||
@user.add_jour(User.current, params[:new_form][:user_message])
|
||||
end
|
||||
redirect_to feedback_path(@user)
|
||||
else
|
||||
render_403
|
||||
end
|
||||
redirect_to feedback_path(@user)
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
</div>
|
||||
<div class="resources mt10" id="users_setting">
|
||||
<div>
|
||||
|
||||
<% if params[:type].nil? %>
|
||||
<div class="newsReadSetting">
|
||||
有 <span class="c_red"><%= User.current.count_new_message %></span> 条未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @message_alls.count >0 %>
|
||||
<%# 课程消息 %>
|
||||
<% unless @message_alls.nil? %>
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
class DeleteAnonymousJour < ActiveRecord::Migration
|
||||
def up
|
||||
jour_count = Journal.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... jour_count do i
|
||||
Journal.page(i).per(30).each do |jour|
|
||||
jour.destroy if jour.user_id == 2
|
||||
end
|
||||
end
|
||||
end
|
||||
Journal.where("user_id = 2").destroy_all
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class DeleteAnonymousFeedback < ActiveRecord::Migration
|
||||
def up
|
||||
JournalsForMessage.where("user_id = 2").destroy_all
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class DeleteAnonymousMessage < ActiveRecord::Migration
|
||||
def up
|
||||
Message.where("author_id = 2").destroy_all
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue