|
|
@@ -1,16 +1,16 @@ |
|
|
|
# redMine - project management software |
|
|
|
# Copyright (C) 2006-2007 Jean-Philippe Lang |
|
|
|
# Redmine - project management software |
|
|
|
# Copyright (C) 2006-2011 Jean-Philippe Lang |
|
|
|
# |
|
|
|
# This program is free software; you can redistribute it and/or |
|
|
|
# modify it under the terms of the GNU General Public License |
|
|
|
# as published by the Free Software Foundation; either version 2 |
|
|
|
# of the License, or (at your option) any later version. |
|
|
|
# |
|
|
|
# |
|
|
|
# This program is distributed in the hope that it will be useful, |
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
# GNU General Public License for more details. |
|
|
|
# |
|
|
|
# |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with this program; if not, write to the Free Software |
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
|
@@ -27,10 +27,10 @@ class MessagesController < ApplicationController |
|
|
|
|
|
|
|
helper :watchers |
|
|
|
helper :attachments |
|
|
|
include AttachmentsHelper |
|
|
|
include AttachmentsHelper |
|
|
|
|
|
|
|
REPLIES_PER_PAGE = 25 unless const_defined?(:REPLIES_PER_PAGE) |
|
|
|
|
|
|
|
|
|
|
|
# Show a topic and its replies |
|
|
|
def show |
|
|
|
page = params[:page] |
|
|
@@ -39,18 +39,18 @@ 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 |
|
|
|
@reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page |
|
|
|
@replies = @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}], |
|
|
|
:order => "#{Message.table_name}.created_on ASC", |
|
|
|
:limit => @reply_pages.items_per_page, |
|
|
|
:offset => @reply_pages.current.offset) |
|
|
|
|
|
|
|
|
|
|
|
@reply = Message.new(:subject => "RE: #{@message.subject}") |
|
|
|
render :action => "show", :layout => false if request.xhr? |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Create a new topic |
|
|
|
def new |
|
|
|
@message = Message.new(params[:message]) |
|
|
@@ -97,7 +97,7 @@ class MessagesController < ApplicationController |
|
|
|
redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Delete a messages |
|
|
|
def destroy |
|
|
|
(render_403; return false) unless @message.destroyable_by?(User.current) |
|
|
@@ -106,7 +106,7 @@ class MessagesController < ApplicationController |
|
|
|
{ :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } : |
|
|
|
{ :action => 'show', :id => @message.parent, :r => @message } |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def quote |
|
|
|
user = @message.author |
|
|
|
text = @message.content |
|
|
@@ -123,14 +123,14 @@ class MessagesController < ApplicationController |
|
|
|
page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;" |
|
|
|
} |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def preview |
|
|
|
message = @board.messages.find_by_id(params[:id]) |
|
|
|
@attachements = message.attachments if message |
|
|
|
@text = (params[:message] || params[:reply])[:content] |
|
|
|
render :partial => 'common/preview' |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
def find_message |
|
|
|
find_board |
|
|
@@ -139,7 +139,7 @@ private |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
render_404 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def find_board |
|
|
|
@board = Board.find(params[:board_id], :include => :project) |
|
|
|
@project = @board.project |