diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 8ef399d10..f5ad89832 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -44,7 +44,8 @@ class MessagesController < ApplicationController
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
page = 1 + offset / REPLIES_PER_PAGE
end
- @reply_count = @topic.children.count
+ all_comments = []
+ @reply_count = get_all_children(all_comments, @topic).count
@reply = Message.new(:subject => "RE: #{@message.subject}")
if @course
messages_replies = @topic.children.
@@ -137,26 +138,32 @@ class MessagesController < ApplicationController
# Reply to a topic
def reply
- if params[:reply][:content] == ""
- if params[:is_board]
- if @project
- (redirect_to project_boards_path(@project), :notice => l(:label_reply_empty);return)
- elsif @course
- (redirect_to course_boards_path(@course), :notice => l(:label_reply_empty);return)
- end
- else
- (redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
- end
+ if params[:parent_id]
+ parent = Message.find params[:parent_id]
+ @reply = Message.new
+ @reply.author = User.current
+ @reply.board = parent.board
+ @reply.content = params[:content]
+ @reply.subject = "RE: #{parent.subject}"
+ @reply.reply_id = params[:reply_id]
+ # @reply.reply_id = params[:id]
+ parent.children << @reply
+ @topic = params[:activity_id].nil? ? parent : Message.find(params[:activity_id].to_i)
+ @user_activity_id = params[:user_activity_id] if params[:user_activity_id]
+ @is_course = params[:is_course] if params[:is_course]
+ @is_board = params[:is_board] if params[:is_board]
+ else
+ @quote = params[:quote][:quote]
+ @reply = Message.new
+ @reply.author = User.current
+ @reply.board = @board
+ @reply.safe_attributes = params[:reply]
+ @reply.content = @quote + @reply.content
+ @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
+ @topic.children << @reply
+ # @reply.reply_id = params[:id]
end
- @quote = params[:quote][:quote]
- @reply = Message.new
- @reply.author = User.current
- @reply.board = @board
- @reply.safe_attributes = params[:reply]
- @reply.content = @quote + @reply.content
- @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
- # @reply.reply_id = params[:id]
- @topic.children << @reply
+
update_course_activity(@topic.class,@topic.id)
update_user_activity(@topic.class,@topic.id)
update_forge_activity(@topic.class,@topic.id)
@@ -182,14 +189,10 @@ class MessagesController < ApplicationController
respond_to do |format|
format.js
end
- elsif params[:is_board]
- if @project
- redirect_to project_boards_path(@project)
- elsif @course
- redirect_to course_boards_path(@course)
- end
+ return
else
- redirect_to board_message_url(@board, @topic, :r => @reply)
+ redirect_to board_message_url(@board, @topic)
+ return
end
end
@@ -251,6 +254,17 @@ class MessagesController < ApplicationController
# Delete a messages
def destroy
+ if params[:user_activity_id]
+ @message.destroy
+ @topic = Message.find(params[:activity_id].to_i)
+ @user_activity_id = params[:user_activity_id]
+ @is_course = params[:is_course]
+ @is_board = params[:is_board]
+ respond_to do |format|
+ format.js
+ end
+ return
+ end
if @project
(render_403; return false) unless @message.destroyable_by?(User.current)
elsif @course
@@ -299,12 +313,12 @@ class MessagesController < ApplicationController
end
def quote
- @subject = @message.subject
- @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
-
- @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
- @temp = Message.new
- @temp.content = "
- <% @replies.each_with_index do |reply,i| %>
+ <% comments.each_with_index do |reply,i| %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
-
-
- <%= reply.content.html_safe%>
-
-
- <%= format_time(reply.created_on) %>
-
-
-
-
-
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, @topic) %>
+
+ <% comments.each_with_index do |reply,i| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
+
+
+
+ <%= link_to reply.creator_user.show_name, user_url_in_org(reply.creator_user.id), :class => "newsBlue mr10 f14" %>
+ <%= time_from_now(reply.created_on) %>
- <% end %>
-
+ <% if !reply.parent.nil? && !reply.parent.parent.nil? %>
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%>
+ <% end %>
+
+ <%= reply.content.html_safe%>
+
+
+
+
+
+ <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %>
+
+
+ <%= link_to(
+ l(:button_reply),
+ {:action => 'quote', :id => reply},
+ :remote => true,
+ :method => 'get',
+ :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %>
+ ︿
+
+ <%= link_to(
+ l(:button_delete),
+ {:action => 'destroy', :id => reply},
+ :method => :post,
+ :class => 'fr mr20',
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete)
+ ) if reply.course_destroyable_by?(User.current) %>
+
- <% end %>
+
+
+
+
+
+
+
+ <% end %>
+
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
diff --git a/app/views/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb
index d4d9d77a0..923734001 100644
--- a/app/views/messages/_reply_message.html.erb
+++ b/app/views/messages/_reply_message.html.erb
@@ -4,11 +4,12 @@
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
+ <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>
+ <%# count = fetch_user_leaveWord_reply(activity).count %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
+ <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %>
- <% activity= activity.parent ? activity.parent : activity%>
- <% comments = activity.children.reorder("created_on desc").limit(3) %>
- <% if count > 0 %>
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, activity)[0..2] %>
+ <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
+ <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id, :is_course => is_course, :is_board =>is_board}%>
<% end %>
diff --git a/app/views/users/_message_contents.html.erb b/app/views/users/_message_contents.html.erb
new file mode 100644
index 000000000..eab125006
--- /dev/null
+++ b/app/views/users/_message_contents.html.erb
@@ -0,0 +1,23 @@
+<% parents_rely = [] %>
+<% parents_rely = get_reply_parents_no_root parents_rely, comment %>
+<% length = parents_rely.length %>
+
\ No newline at end of file
diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb
new file mode 100644
index 000000000..c6f9d91b0
--- /dev/null
+++ b/app/views/users/_message_replies.html.erb
@@ -0,0 +1,61 @@
+
+ <% comments.each do |comment| %>
+
+ -
+
+ <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
+
+
+
+ <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %>
+ <%= time_from_now(comment.created_on) %>
+
+ <% if !comment.parent.nil? && !comment.parent.parent.nil? %>
+ <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
+ <% end %>
+ <% if !comment.content_detail.blank? %>
+
+
+
+
+
+
+ <%= link_to(
+ l(:button_reply),
+ {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id, :is_course => is_course, :is_board => is_board},
+ :remote => true,
+ :method => 'get',
+ :title => l(:button_reply)) %>
+
+
+ <% if comment.course_destroyable_by?(User.current) %>
+ <%= link_to(
+ l(:button_delete),
+ delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id, :is_course => is_course, :is_board => is_board),
+ :method => :post,
+ :remote => true,
+ :class => 'fr mr20',
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete)
+ ) %>
+ <% end %>
+
+
+
+
+
+ <% end %>
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_message_reply_banner.html.erb b/app/views/users/_message_reply_banner.html.erb
new file mode 100644
index 000000000..0c8cda379
--- /dev/null
+++ b/app/views/users/_message_reply_banner.html.erb
@@ -0,0 +1,18 @@
+
+
+ 回复
+ ︿
+ <%= count>0 ? "(#{count})" : "" %>▪
+
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index 1abc36a31..d1bb99296 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -77,20 +77,18 @@
- <% count = 0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
+ <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>
+ <%# count = fetch_user_leaveWord_reply(activity).count %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
+ <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %>
- <% activity= activity.parent_id.nil? ? activity : activity.parent %>
- <% comments = activity.children.reorder("created_on desc").limit(3) %>
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, activity)[0..2] %>
<% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
+ <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id, :is_course => is_course, :is_board =>is_board}%>
<% end %>
diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb
index 621b56fbd..8a2909ad4 100644
--- a/app/views/users/_reply_to.html.erb
+++ b/app/views/users/_reply_to.html.erb
@@ -16,7 +16,7 @@
<% end%>
<% elsif @type == 'JournalsForMessage' %>
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%>
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%>
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %>
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => reply.user.id %>
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => reply.id %>
@@ -28,6 +28,22 @@
发送
<% end%>
+ <% elsif @type == 'Message' %>
+ <%= form_for('new_form',:url => {:controller => 'messages', :action => 'reply', :id => reply.id, :board_id => reply.board.id}, :method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'is_course', params[:is_course], :value => @is_course %>
+ <%= hidden_field_tag 'is_board', params[:is_board], :value => @is_board %>
+ <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %>
+ <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author.id %>
+ <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %>
+
+
+
+
发送
+
+
+ <% end%>
<% end %>
diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb
index 6d227e93b..d03e13742 100644
--- a/app/views/users/all_journals.js.erb
+++ b/app/views/users/all_journals.js.erb
@@ -2,6 +2,8 @@
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>');
<% elsif params[:type] == 'JournalsForMessage' %>
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>');
+<% elsif params[:type] == 'Message' %>
+$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>');
<% else %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>');
<% end %>
diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb
index 5f5ea6c3f..ae8803653 100644
--- a/app/views/users/show_all_replies.js.erb
+++ b/app/views/users/show_all_replies.js.erb
@@ -1,6 +1,8 @@
<% unless @comment.parent.nil? %>
<% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %>
$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>");
+ <% elsif @comment.class.to_s == 'Message' %>
+ $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>");
<% else %>
$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>");
<% end %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 016526512..91467cca4 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1374,6 +1374,41 @@ function expand_journal_reply(container, btnid, id, type, div_id, allow_delete)
}
}
+function expand_message_reply(container, btnid, id, type, div_id, is_course, is_board) {
+ var target = $(container);
+ var btn = $(btnid);
+ if (btn.data('init') == '0') {
+ btn.data('init', 1);
+ $.get(
+ '/users/all_journals',
+ {
+ type: type,
+ id: id,
+ div_id: div_id,
+ is_course: is_course,
+ is_board: is_board
+ },
+ function(data) {
+
+ }
+ );
+ btn.html('收起回复');
+ //target.show();
+ } else if(btn.data('init') == '1') {
+ btn.data('init', 3);
+ btn.html('展开更多');
+ target.hide();
+ target.eq(0).show();
+ target.eq(1).show();
+ target.eq(2).show();
+ }
+ else {
+ btn.data('init', 1);
+ btn.html('收起回复');
+ target.show();
+ }
+}
+
function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) {
var target = $(container);
var btn = $(btnid);
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 96c9947b1..9f7aeeafc 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -190,7 +190,7 @@ a.postOptionLink2:hover {color:#ffffff; background-color:#269ac9;}
.imageFuzzy {filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5;opacity: 0.5;}
.homepagePostReplyDes {float:left; width:632px; margin-left:15px;}
.homepagePostReplyPublisher {font-size:12px; color:#888888; margin-bottom:5px;}
-.homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;}
+.homepagePostReplyContent {font-size:12px; color:#484848; margin:3px 5px 12px 5px;}
.homepagePostReplyContent ol li{list-style-type: decimal;margin-left: 20px;}
.homepagePostReplyContent ul li{list-style-type: disc;margin-left: 20px;}
.homepagePostReplyContent td,.homepagePostReplyContent tr {border: 1px solid; border-color: inherit;}
@@ -1429,4 +1429,4 @@ a.pages-big{ width:50px;}
.W300 {width:300px !important;}
.W600{ width:600px;}
-.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;}
+.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;}
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 7cfb7f9e0..154cda201 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -666,7 +666,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostReplyPortrait {float:left; width:45px;}
.homepagePostReplyDes {float:left; width:620px; margin-left:15px;}
.homepagePostReplyPublisher {font-size:12px; color:#484848; margin-bottom:5px;}
-.homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;}
+.homepagePostReplyContent {font-size:12px; color:#484848; margin:3px 5px 12px 5px;}
.homepagePostReplyContent ol li{list-style-type: decimal;margin-left: 40px;}
.homepagePostReplyContent ul li{list-style-type: disc;margin-left: 40px;}
.homepagePostReplyContent td,.homepagePostReplyContent tr {border: 1px solid; border-color: inherit;}
@@ -1184,4 +1184,46 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px;
.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
/*20160622代码分析弹窗*/
-.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
+.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
+
+/* 二级回复 */
+.clearfix:after { content:"."; display:block; height:0; visibility:hidden; clear:both; }
+.clearfix { zoom:1; }
+.clearit { clear:both; height:0; font-size:0; overflow:hidden; }
+.comment_item{ width:720px; background-color:#f1f1f1; color:#888;}
+.comment_top{ height:15px; border: 1px solid #e4e4e4; padding:10px; position:relative;}
+.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
+.fl{ float:left;}
+.fr{ float:right;}
+.comment_item_cont{ padding:15px; border-bottom:1px solid #e3e3e3;}
+.J_Comment_Face img{ width:40px; height:40px; }
+.t_content{ width:92%; margin-left:15px;}
+a.content-username { color:#269ac9; font-size:14px; margin-right:15px;}
+a.content-username:hover{ color:#297fb8;}
+.orig_user img{width:32px; height:32px;}
+.reply-right{ float:right; position:relative;}
+.reply_iconup02{ position:absolute; top:16px; left:4px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
+.comment_orig_content{margin:10px 0; color:#999;}
+.comment_orig_content .comment_orig_content{margin-top:0;}
+.orig_cont{ border:solid 1px #F3DDB3; background:#FFFEF4; padding:4px;color:#999;margin-top:-1px;}
+.orig_cont_sub{ border-top:0}
+.orig_index{ float:right; color:#666; font-family:Arial; padding-right:5px;line-height:30px;}
+.orig_user{ margin:10px 15px 10px 5px;}
+.orig_user span{ color:#999; padding-right:5px;}
+.orig_content{padding:5px 0px 5px 0px;line-height:24px; color:#333; }
+.orig_right{ width:80%; margin-top:5px;}
+a.comment_ding_link{ height:24px;line-height:24px;display:inline-block;padding-left:2px;vertical-align:middle; color:#333; }
+a:hover.comment_ding_link{ color:#269ac9;}
+.comment_ding_link span{display: inline-block;padding: 0 0px 0 8px;}
+.comment_ding_link em{font-style: normal;font-family: arial;}
+.comment_reply_link{ display:inline-block; width:50px; height:24px;line-height: 24px; vertical-align:middle;text-align: center;}
+.comment_reply_link:link,.comment_reply_link:visited{color:#333;text-decoration: none;}
+.comment_content{ color:#333;}
+.t_txt{ margin-top:10px;}
+.orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;}
+.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;}
+.orig_textarea{width:90%; margin-bottom:10px;}
+.orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;}
+.orig_sub:hover{ background:#297fb8;}
+.orig_cont_hide{ text-align:center; width:624px; display:block; font-size:14px; color:#333; border-bottom:1px solid #F3DDB3; padding:8px 0;}
+.orig_icon{ color:#888; margin-right:10px; font-size:14px; font-weight:bold;}