|
|
|
@ -38,47 +38,45 @@ class MessagesController < ApplicationController
|
|
|
|
|
# Show a topic and its replies
|
|
|
|
|
def show
|
|
|
|
|
@isReply = true
|
|
|
|
|
page = params[:page]
|
|
|
|
|
# Find the page of the requested reply
|
|
|
|
|
if params[:r] && page.nil?
|
|
|
|
|
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
|
|
|
|
|
page = 1 + offset / REPLIES_PER_PAGE
|
|
|
|
|
end
|
|
|
|
|
# page = params[:page]
|
|
|
|
|
# # Find the page of the requested reply
|
|
|
|
|
# if params[:r] && page.nil?
|
|
|
|
|
# offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
|
|
|
|
|
# page = 1 + offset / REPLIES_PER_PAGE
|
|
|
|
|
# end
|
|
|
|
|
all_comments = []
|
|
|
|
|
@reply_count = get_all_children(all_comments, @topic).count
|
|
|
|
|
@replies = get_all_children(all_comments, @topic)
|
|
|
|
|
@reply_count = @replies.count
|
|
|
|
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
|
|
|
|
if @course
|
|
|
|
|
messages_replies = @topic.children.
|
|
|
|
|
includes(:author, :attachments, {:board => :project}).
|
|
|
|
|
reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
#@replies = @topic.children.
|
|
|
|
|
#includes(:author, :attachments, :praise_tread_cache, {:board => :project}).
|
|
|
|
|
#reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
#limit(@reply_pages.per_page).
|
|
|
|
|
#offset(@reply_pages.offset).
|
|
|
|
|
all
|
|
|
|
|
@replies = paginateHelper messages_replies,10
|
|
|
|
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
|
|
|
|
#all
|
|
|
|
|
#@replies = paginateHelper messages_replies,10
|
|
|
|
|
@left_nav_type = 2
|
|
|
|
|
render :action => "show", :layout => "base_courses"#by young
|
|
|
|
|
elsif @project
|
|
|
|
|
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
|
|
|
|
|
@replies = @topic.children.
|
|
|
|
|
includes(:author, :attachments, {:board => :project}).
|
|
|
|
|
reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
limit(@reply_pages.per_page).
|
|
|
|
|
offset(@reply_pages.offset).
|
|
|
|
|
all
|
|
|
|
|
#@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
|
|
|
|
|
# @replies = @topic.children.
|
|
|
|
|
# includes(:author, :attachments, {:board => :project}).
|
|
|
|
|
# reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
# limit(@reply_pages.per_page).
|
|
|
|
|
# offset(@reply_pages.offset).
|
|
|
|
|
# all
|
|
|
|
|
|
|
|
|
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
|
|
|
|
render :action => "show", :layout => "base_projects"#by young
|
|
|
|
|
else
|
|
|
|
|
@reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
|
|
|
|
|
@replies = @topic.children.
|
|
|
|
|
includes(:author, :attachments, {:board => :project}).
|
|
|
|
|
reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
limit(@reply_pages.per_page).
|
|
|
|
|
offset(@reply_pages.offset).
|
|
|
|
|
all
|
|
|
|
|
# @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
|
|
|
|
|
# @replies = @topic.children.
|
|
|
|
|
# includes(:author, :attachments, {:board => :project}).
|
|
|
|
|
# reorder("#{Message.table_name}.created_on DESC").
|
|
|
|
|
# limit(@reply_pages.per_page).
|
|
|
|
|
# offset(@reply_pages.offset).
|
|
|
|
|
# all
|
|
|
|
|
|
|
|
|
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
|
|
|
|
@organization = @org_subfield.organization
|
|
|
|
|
render :action => "show", :layout => "base_org"#by young
|
|
|
|
|
end
|
|
|
|
|