2014-10-23 11:30:34 +08:00
|
|
|
|
# encoding: utf-8
|
|
|
|
|
#####leave message fq
|
|
|
|
|
class WordsController < ApplicationController
|
2015-04-03 11:19:15 +08:00
|
|
|
|
include ApplicationHelper
|
2014-10-23 11:30:34 +08:00
|
|
|
|
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
|
2015-11-30 21:52:05 +08:00
|
|
|
|
before_filter :require_login, :only => [:create_reply]
|
|
|
|
|
|
2014-10-23 11:30:34 +08:00
|
|
|
|
def create
|
2015-07-29 18:00:35 +08:00
|
|
|
|
if params[:new_form][:user_message].size>0 && User.current.logged?
|
2014-10-23 11:30:34 +08:00
|
|
|
|
unless params[:user_id].nil?
|
|
|
|
|
if params[:reference_content]
|
|
|
|
|
message = params[:new_form][:user_message] + "\n" + params[:reference_content]
|
|
|
|
|
else
|
|
|
|
|
message = params[:new_form][:user_message]
|
|
|
|
|
end
|
|
|
|
|
refer_user_id = params[:new_form][:reference_user_id].to_i
|
|
|
|
|
|
2015-07-10 14:17:19 +08:00
|
|
|
|
list = @user.add_jour(User.current, message, refer_user_id)
|
2014-10-23 11:30:34 +08:00
|
|
|
|
unless refer_user_id == 0 || refer_user_id == User.current.id
|
2015-07-10 14:17:19 +08:00
|
|
|
|
list = User.find(refer_user_id).add_jour(User.current, message, refer_user_id)
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
2015-07-10 14:17:19 +08:00
|
|
|
|
@jour = list.last
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2015-07-29 18:26:04 +08:00
|
|
|
|
jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
|
|
|
|
@jour = paginateHelper jours,10
|
2014-10-23 11:30:34 +08:00
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_reply
|
|
|
|
|
# 这里是创建回复所使用的方法,此方法只针对回复,每一个新的留言并不在此方法管理范围内。
|
|
|
|
|
# 由于多个地方用到了留言,而之前的表设计也有jour_type/jour_id这类信息
|
|
|
|
|
# 所以在方法 add_reply_adapter 中判断所有调用此方法的来源页面,
|
|
|
|
|
# 为了保证兼容以往所有的代码,保证以往的方法可以调用,在返回页面中都做了各式各样的判断。
|
|
|
|
|
# 页面保证 render new_respond/journal_reply
|
|
|
|
|
# 修改 add_reply_adapter 中可以确保留言创建成功
|
|
|
|
|
# 删除留言功能要调用destroy,也记得在destroy.js中修改
|
|
|
|
|
|
|
|
|
|
# deny api. api useless
|
2015-09-25 16:29:47 +08:00
|
|
|
|
parent_id = params[:reference_id]
|
2014-10-23 11:30:34 +08:00
|
|
|
|
author_id = User.current.id
|
|
|
|
|
reply_user_id = params[:reference_user_id]
|
|
|
|
|
reply_id = params[:reference_message_id] # 暂时不实现
|
|
|
|
|
content = params[:user_notes]
|
2014-11-04 14:49:36 +08:00
|
|
|
|
@show_name = params[:show_name] == "true"
|
2014-10-23 11:30:34 +08:00
|
|
|
|
options = {:user_id => author_id,
|
|
|
|
|
:status => true,
|
2015-09-25 16:29:47 +08:00
|
|
|
|
:m_parent_id => parent_id,
|
2014-10-23 11:30:34 +08:00
|
|
|
|
:m_reply_id => reply_id,
|
|
|
|
|
:reply_id => reply_user_id,
|
|
|
|
|
:notes => content,
|
|
|
|
|
:is_readed => false}
|
2016-06-23 14:47:22 +08:00
|
|
|
|
@activity = params[:activity_id].nil? ? JournalsForMessage.find(parent_id) : JournalsForMessage.find(params[:activity_id].to_i)
|
|
|
|
|
@jfm = add_reply_adapter(@activity, options)
|
2015-09-25 16:29:47 +08:00
|
|
|
|
@save_succ = true if @jfm.errors.empty?
|
|
|
|
|
if @save_succ
|
2016-06-23 14:47:22 +08:00
|
|
|
|
update_course_activity('JournalsForMessage',@activity.id)
|
|
|
|
|
update_user_activity('JournalsForMessage',@activity.id)
|
|
|
|
|
update_forge_activity('JournalsForMessage',@activity.id)
|
|
|
|
|
update_org_activity('JournalsForMessage',@activity.id)
|
|
|
|
|
update_principal_activity('JournalsForMessage',@activity.id)
|
|
|
|
|
@activity.update_attribute(:updated_on,Time.now)
|
2015-09-25 16:29:47 +08:00
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
respond_to do |format|
|
|
|
|
|
# format.html {
|
|
|
|
|
# if @jfm.errors.empty?
|
|
|
|
|
# flash.now.notice = l(:label_feedback_success)
|
|
|
|
|
# else
|
|
|
|
|
# flash.now.errors = l(:label_feedback_fail)
|
|
|
|
|
# end
|
|
|
|
|
# render 'test/index'
|
|
|
|
|
# }
|
2015-09-25 16:29:47 +08:00
|
|
|
|
format.js {
|
2016-02-23 15:22:44 +08:00
|
|
|
|
#@reply_type = params[:reply_type]
|
2015-10-14 11:38:16 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id]
|
2014-10-23 11:30:34 +08:00
|
|
|
|
}
|
|
|
|
|
end
|
2015-09-25 16:29:47 +08:00
|
|
|
|
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
2015-08-21 17:00:17 +08:00
|
|
|
|
@journal_destroyed = JournalsForMessage.find params[:object_id]
|
|
|
|
|
if @journal_destroyed.destroy
|
|
|
|
|
if @journal_destroyed.jour_type == "Bid"
|
|
|
|
|
@bid = Bid.find(@journal_destroyed.jour_id)
|
|
|
|
|
@jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
|
|
|
|
|
elsif @journal_destroyed.jour_type == "Course"
|
|
|
|
|
@course = Course.find @journal_destroyed.jour_id
|
|
|
|
|
@jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count
|
2016-06-23 14:47:22 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
|
|
|
|
|
@activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
|
2015-08-21 17:00:17 +08:00
|
|
|
|
elsif @journal_destroyed.jour_type == "Principal"
|
|
|
|
|
@user = User.find(@journal_destroyed.jour_id)
|
|
|
|
|
@jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count
|
|
|
|
|
@is_user = true
|
2016-01-25 15:33:50 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
|
2016-06-23 14:47:22 +08:00
|
|
|
|
@activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
|
2016-02-23 15:22:44 +08:00
|
|
|
|
unless @activity
|
|
|
|
|
redirect_to feedback_path(@user)
|
|
|
|
|
return
|
|
|
|
|
end
|
2015-12-07 11:25:41 +08:00
|
|
|
|
elsif @journal_destroyed.jour_type == 'HomeworkCommon'
|
|
|
|
|
@homework = HomeworkCommon.find @journal_destroyed.jour_id
|
|
|
|
|
if params[:user_activity_id]
|
2016-06-12 14:59:00 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id].to_i
|
2015-12-07 11:25:41 +08:00
|
|
|
|
else
|
|
|
|
|
@user_activity_id = -1
|
|
|
|
|
end
|
2016-09-19 17:14:14 +08:00
|
|
|
|
@hw_status = params[:hw_status].to_i
|
2016-09-21 10:34:38 +08:00
|
|
|
|
@is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin?
|
2016-07-25 13:56:26 +08:00
|
|
|
|
elsif @journal_destroyed.jour_type == 'Syllabus'
|
|
|
|
|
@syllabus = Syllabus.find @journal_destroyed.jour_id
|
|
|
|
|
@count = @syllabus.journals_for_messages.count
|
|
|
|
|
@comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3)
|
2015-08-21 17:00:17 +08:00
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroyJournal
|
|
|
|
|
@journalP=JournalsForMessage.find(params[:object_id])
|
|
|
|
|
@journalP.destroy
|
|
|
|
|
|
|
|
|
|
@page = params[:page]
|
|
|
|
|
@page = @page.to_i
|
|
|
|
|
@project = Project.find params[:project_id]
|
|
|
|
|
# Find the page of the requested reply
|
|
|
|
|
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
|
|
|
|
@limit = 10
|
|
|
|
|
|
|
|
|
|
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
|
|
|
|
page = 1 + offset / @limit
|
|
|
|
|
if params[:r] && @page.nil?
|
|
|
|
|
@page = page
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if @page < 0
|
|
|
|
|
@page = 1
|
|
|
|
|
end
|
|
|
|
|
if @page > page
|
|
|
|
|
@page = page
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, @page
|
|
|
|
|
@offset ||= @feedback_pages.offset
|
|
|
|
|
@jour = @jours[@offset, @limit]
|
|
|
|
|
@state = false
|
|
|
|
|
@base_courses_tag = @project.project_type
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
|
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
|
|
|
|
if @jour
|
|
|
|
|
user = @jour.user
|
|
|
|
|
text = @jour.notes
|
|
|
|
|
else
|
|
|
|
|
user = @user
|
|
|
|
|
text = []
|
|
|
|
|
end
|
|
|
|
|
# Replaces pre blocks with [...]
|
|
|
|
|
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
|
|
|
|
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
|
|
|
|
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
|
|
|
|
|
|
|
|
|
# @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
|
|
|
|
# @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
|
|
|
|
|
|
|
|
|
@id = user.id
|
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
|
render_404
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def more
|
|
|
|
|
@jours = @user.journals_for_messages.reverse
|
|
|
|
|
@limit = 10
|
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
|
|
@offset ||= @feedback_pages.offset
|
|
|
|
|
@jour = @jours[@offset, @limit]
|
|
|
|
|
@state = true
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
|
format.js
|
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def back
|
|
|
|
|
@jours = @user.journals_for_messages.reverse
|
|
|
|
|
@limit = 10
|
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
|
|
@offset ||= @feedback_pages.offset
|
|
|
|
|
@jour = @jours[@offset, @limit]
|
|
|
|
|
@state = false
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
|
format.js
|
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def add_project_respond
|
|
|
|
|
user = User.current
|
|
|
|
|
message = params[:new_form][:project_message]
|
|
|
|
|
Project.add_jour(user, message)
|
|
|
|
|
|
|
|
|
|
redirect_to project_feedback_url('trustie')
|
|
|
|
|
# redirect_to signin_path
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def leave_project_message
|
|
|
|
|
user = User.current
|
|
|
|
|
message = params[:new_form][:project_message]
|
|
|
|
|
feedback = Project.add_new_jour(user, message, params[:id])
|
|
|
|
|
if(feedback.errors.empty?)
|
|
|
|
|
redirect_to project_feedback_url(params[:id]), notice: l(:label_feedback_success)
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
redirect_to project_feedback_url(params[:id])
|
|
|
|
|
end
|
2015-07-29 18:26:04 +08:00
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
|
2015-07-29 18:26:04 +08:00
|
|
|
|
#给用户留言
|
|
|
|
|
def leave_user_message
|
2015-09-06 17:06:05 +08:00
|
|
|
|
if User.current.logged?
|
|
|
|
|
@user = User.find(params[:id])
|
2016-01-20 18:37:47 +08:00
|
|
|
|
if params[:new_form][:content].size>0 && User.current.logged? && @user
|
2016-01-06 16:22:13 +08:00
|
|
|
|
if params[:private] && params[:private] == '1'
|
2016-01-20 18:37:47 +08:00
|
|
|
|
@user.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:content], :reply_id => 0, :status => true, :is_readed => false, :private => 1)
|
2016-01-06 16:22:13 +08:00
|
|
|
|
else
|
2016-01-20 18:37:47 +08:00
|
|
|
|
@user.add_jour(User.current, params[:new_form][:content])
|
2016-01-06 16:22:13 +08:00
|
|
|
|
end
|
2015-09-06 17:06:05 +08:00
|
|
|
|
end
|
|
|
|
|
redirect_to feedback_path(@user)
|
|
|
|
|
else
|
|
|
|
|
render_403
|
2015-07-29 18:26:04 +08:00
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# add by nwb
|
|
|
|
|
def leave_course_message
|
|
|
|
|
user = User.current
|
|
|
|
|
message = params[:new_form][:course_message]
|
|
|
|
|
feedback = Course.add_new_jour(user, message, params[:id])
|
|
|
|
|
if(feedback.errors.empty?)
|
2015-04-03 16:35:46 +08:00
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success)
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
redirect_to course_feedback_url(params[:id])
|
|
|
|
|
end
|
2015-10-22 09:20:19 +08:00
|
|
|
|
end
|
|
|
|
|
|
2016-06-30 10:44:11 +08:00
|
|
|
|
#课程大纲的回复
|
|
|
|
|
def leave_syllabus_message
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
@user = User.current
|
|
|
|
|
@syllabus = Syllabus.find(params[:id]);
|
|
|
|
|
if params[:comment].size>0 && User.current.logged? && @user
|
|
|
|
|
feedback = Syllabus.add_syllabus_jour(@user, params[:comment], params[:id])
|
|
|
|
|
if (feedback.errors.empty?)
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
|
|
|
|
end
|
|
|
|
|
redirect_to syllabus_path(@syllabus)
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-10-22 09:20:19 +08:00
|
|
|
|
#作业的回复
|
|
|
|
|
def leave_homework_message
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
@user = User.current
|
|
|
|
|
@homework_common = HomeworkCommon.find(params[:id]);
|
|
|
|
|
if params[:homework_message].size>0 && User.current.logged? && @user
|
|
|
|
|
feedback = HomeworkCommon.add_homework_jour(@user, params[:homework_message], params[:id])
|
|
|
|
|
if (feedback.errors.empty?)
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
|
|
|
|
end
|
2016-05-06 22:23:05 +08:00
|
|
|
|
@homework_common.update_column('updated_at', Time.now)
|
2016-01-12 15:53:15 +08:00
|
|
|
|
update_course_activity(@homework_common.class,@homework_common.id)
|
|
|
|
|
update_user_activity(@homework_common.class,@homework_common.id)
|
|
|
|
|
update_org_activity(@homework_common.class,@homework_common.id)
|
2015-10-22 09:20:19 +08:00
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js{
|
2016-09-19 17:14:14 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id].to_i
|
|
|
|
|
@hw_status = params[:hw_status].to_i
|
2016-09-21 10:34:38 +08:00
|
|
|
|
@is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin?
|
2015-10-22 09:20:19 +08:00
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
2016-05-06 17:36:28 +08:00
|
|
|
|
|
|
|
|
|
#作业的二级回复
|
|
|
|
|
def reply_to_homework
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
@user = User.current
|
|
|
|
|
reply = JournalsForMessage.find params[:id].to_i
|
|
|
|
|
@homework_common = HomeworkCommon.find reply.jour_id
|
|
|
|
|
if params[:reply_message].size>0 && User.current.logged? && @user
|
|
|
|
|
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
|
|
|
|
|
feedback = HomeworkCommon.add_homework_jour(@user, params[:reply_message], reply.jour_id, options)
|
|
|
|
|
if (feedback.errors.empty?)
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
|
|
|
|
end
|
2016-05-06 22:23:05 +08:00
|
|
|
|
@homework_common.update_column('updated_at', Time.now)
|
2016-05-06 17:36:28 +08:00
|
|
|
|
update_course_activity(@homework_common.class,@homework_common.id)
|
|
|
|
|
update_user_activity(@homework_common.class,@homework_common.id)
|
|
|
|
|
update_org_activity(@homework_common.class,@homework_common.id)
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js{
|
2016-05-09 17:06:10 +08:00
|
|
|
|
@user_activity_id = params[:user_activity_id].to_i
|
2016-09-19 17:14:14 +08:00
|
|
|
|
@hw_status = params[:hw_status].to_i
|
2016-09-21 10:34:38 +08:00
|
|
|
|
@is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin?
|
2016-05-06 17:36:28 +08:00
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-07-25 13:56:26 +08:00
|
|
|
|
|
|
|
|
|
#课程大纲的二级回复
|
|
|
|
|
def reply_to_syllabus
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
@user = User.current
|
|
|
|
|
reply = JournalsForMessage.find params[:id].to_i
|
|
|
|
|
@syllabus = Syllabus.find reply.jour_id
|
|
|
|
|
if params[:reply_message].size>0 && User.current.logged? && @user
|
|
|
|
|
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
|
|
|
|
|
feedback = Syllabus.add_syllabus_jour(@user, params[:reply_message], reply.jour_id, options)
|
|
|
|
|
if (feedback.errors.empty?)
|
|
|
|
|
if params[:asset_id]
|
|
|
|
|
ids = params[:asset_id].split(',')
|
|
|
|
|
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
|
|
|
|
end
|
|
|
|
|
@syllabus.update_column('updated_at', Time.now)
|
|
|
|
|
@count = @syllabus.journals_for_messages.count
|
|
|
|
|
@comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3)
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
flash[:error] = feedback.errors.full_messages[0]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
|
|
|
|
|
def add_brief_introdution
|
|
|
|
|
user = User.current
|
|
|
|
|
message = params[:new_form][:user_introduction]
|
|
|
|
|
UserExtensions.introduction(user, message)
|
|
|
|
|
redirect_to user_url(user.id)
|
|
|
|
|
end
|
2016-06-22 14:04:47 +08:00
|
|
|
|
|
|
|
|
|
#邮箱激活问题留言 留言成功给出提示框
|
|
|
|
|
def leave_email_activation_message
|
|
|
|
|
status = 1 #成功
|
|
|
|
|
me = User.find(params[:user])
|
|
|
|
|
if me
|
2016-06-22 14:14:36 +08:00
|
|
|
|
#课程使者id=1
|
|
|
|
|
@user = User.find(1)
|
2016-06-22 14:04:47 +08:00
|
|
|
|
if params[:text].size>0 && @user
|
|
|
|
|
# @user.add_jour(me, params[:text])
|
|
|
|
|
#私信
|
|
|
|
|
message = "<span style='color:red;'>【未收到激活邮件的用户反馈,用户邮箱:"+me.mail+"】</span><br>"+params[:text]
|
|
|
|
|
@user.journals_for_messages << JournalsForMessage.new(:user_id => me.id, :notes => message, :reply_id => 0, :status => true, :is_readed => false, :private => 1)
|
|
|
|
|
else
|
|
|
|
|
status = 0
|
|
|
|
|
end
|
|
|
|
|
render :json => status
|
|
|
|
|
else
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def find_user
|
|
|
|
|
if params[:user_id]
|
|
|
|
|
@user = User.find(params[:user_id])
|
|
|
|
|
end
|
|
|
|
|
rescue
|
|
|
|
|
render_404
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def obj_distinguish_url_origin
|
|
|
|
|
#modify by nwb
|
|
|
|
|
#添加对课程留言的支持
|
|
|
|
|
referer = request.headers["Referer"]
|
2014-10-29 09:52:33 +08:00
|
|
|
|
#referer = "http://forge.trustie.net/words/create_reply"
|
2014-10-23 11:30:34 +08:00
|
|
|
|
obj_id = referer.match(%r(/([0-9]{1,})(/|\?|$)))[1]
|
|
|
|
|
if referer.match(/project/)
|
|
|
|
|
obj = Project.find_by_id(obj_id)
|
|
|
|
|
elsif referer.match(/user/)
|
|
|
|
|
obj = User.find_by_id(obj_id)
|
|
|
|
|
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
|
|
|
|
obj = Bid.find_by_id(obj_id)
|
|
|
|
|
elsif ( referer.match(/contests/) || referer.match(/contests/) ) #new added
|
|
|
|
|
obj = Contest.find_by_id(obj_id)
|
|
|
|
|
elsif ( referer.match(/softapplications/) || referer.match(/softapplications/) ) #new added
|
|
|
|
|
obj = Softapplication.find_by_id(obj_id)
|
|
|
|
|
elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added
|
|
|
|
|
obj = HomeworkAttach.find_by_id(obj_id)
|
2014-10-29 09:52:33 +08:00
|
|
|
|
elsif referer.match(/course/)
|
|
|
|
|
obj = Course.find_by_id(obj_id)
|
2014-10-23 11:30:34 +08:00
|
|
|
|
else
|
2014-12-11 09:24:22 +08:00
|
|
|
|
#raise "create reply obj unknow type.#{referer}"
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
obj
|
|
|
|
|
end
|
|
|
|
|
|
2016-06-23 14:47:22 +08:00
|
|
|
|
def add_reply_adapter obj, options
|
2014-10-23 11:30:34 +08:00
|
|
|
|
#modify by nwb
|
|
|
|
|
#添加对课程留言的支持
|
2014-12-11 09:24:22 +08:00
|
|
|
|
#留言回复应该不关系其所属的Class,而关心的是其所属的父留言
|
2016-06-23 14:47:22 +08:00
|
|
|
|
case obj.jour_type
|
|
|
|
|
when 'Principal'
|
|
|
|
|
obj.jour.add_jour(nil, nil, nil, options)
|
|
|
|
|
when 'Project'
|
|
|
|
|
Project.add_new_jour(nil, nil, obj.jour_id, options)
|
|
|
|
|
when 'Course'
|
|
|
|
|
Course.add_new_jour(nil, nil, obj.jour_id, options)
|
|
|
|
|
when 'Bid'
|
|
|
|
|
obj.jour.add_jour(nil, nil, nil, options)
|
|
|
|
|
when 'Contest'
|
|
|
|
|
obj.jour.add_jour(nil, nil, obj.jour_id, options)
|
|
|
|
|
when 'Softapplication'
|
|
|
|
|
obj.jour.add_jour(nil, nil, obj.jour_id, options)
|
|
|
|
|
when 'HomeworkAttach'
|
|
|
|
|
obj.jour.add_jour(nil, nil, obj.jour_id, options)
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
2016-06-23 14:47:22 +08:00
|
|
|
|
# obj = obj_distinguish_url_origin || User.find_by_id(2)
|
|
|
|
|
# if obj.kind_of? User
|
|
|
|
|
# obj.add_jour(nil, nil, nil, options)
|
|
|
|
|
# elsif obj.kind_of? Project
|
|
|
|
|
# Project.add_new_jour(nil, nil, obj.id, options)
|
|
|
|
|
# elsif obj.kind_of? Course
|
|
|
|
|
# Course.add_new_jour(nil, nil, obj.id, options)
|
|
|
|
|
# elsif obj.kind_of? Bid
|
|
|
|
|
# obj.add_jour(nil, nil, nil, options)
|
|
|
|
|
# elsif obj.kind_of? Contest
|
|
|
|
|
# obj.add_jour(nil, nil, obj.id, options) #new added
|
|
|
|
|
# elsif obj.kind_of? Softapplication
|
|
|
|
|
# obj.add_jour(nil, nil, obj.id, options) #new added
|
|
|
|
|
# elsif obj.kind_of? HomeworkAttach
|
|
|
|
|
# obj.add_jour(nil, nil, obj.id, options) #new added
|
|
|
|
|
# else
|
|
|
|
|
# raise "create reply obj unknow type.#{obj.class}"
|
|
|
|
|
# end
|
2014-10-23 11:30:34 +08:00
|
|
|
|
end
|
|
|
|
|
#######end of message
|
|
|
|
|
end
|