@@ -1,16 +1,16 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -27,10 +27,10 class MessagesController < ApplicationController | |||
|
27 | 27 | |
|
28 | 28 | helper :watchers |
|
29 | 29 | helper :attachments |
|
30 |
include AttachmentsHelper |
|
|
30 | include AttachmentsHelper | |
|
31 | 31 | |
|
32 | 32 | REPLIES_PER_PAGE = 25 unless const_defined?(:REPLIES_PER_PAGE) |
|
33 | ||
|
33 | ||
|
34 | 34 | # Show a topic and its replies |
|
35 | 35 | def show |
|
36 | 36 | page = params[:page] |
@@ -39,18 +39,18 class MessagesController < ApplicationController | |||
|
39 | 39 | offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) |
|
40 | 40 | page = 1 + offset / REPLIES_PER_PAGE |
|
41 | 41 | end |
|
42 | ||
|
42 | ||
|
43 | 43 | @reply_count = @topic.children.count |
|
44 | 44 | @reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page |
|
45 | 45 | @replies = @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}], |
|
46 | 46 | :order => "#{Message.table_name}.created_on ASC", |
|
47 | 47 | :limit => @reply_pages.items_per_page, |
|
48 | 48 | :offset => @reply_pages.current.offset) |
|
49 | ||
|
49 | ||
|
50 | 50 | @reply = Message.new(:subject => "RE: #{@message.subject}") |
|
51 | 51 | render :action => "show", :layout => false if request.xhr? |
|
52 | 52 | end |
|
53 | ||
|
53 | ||
|
54 | 54 | # Create a new topic |
|
55 | 55 | def new |
|
56 | 56 | @message = Message.new(params[:message]) |
@@ -97,7 +97,7 class MessagesController < ApplicationController | |||
|
97 | 97 | redirect_to :action => 'show', :board_id => @message.board, :id => @message.root, :r => (@message.parent_id && @message.id) |
|
98 | 98 | end |
|
99 | 99 | end |
|
100 | ||
|
100 | ||
|
101 | 101 | # Delete a messages |
|
102 | 102 | def destroy |
|
103 | 103 | (render_403; return false) unless @message.destroyable_by?(User.current) |
@@ -106,7 +106,7 class MessagesController < ApplicationController | |||
|
106 | 106 | { :controller => 'boards', :action => 'show', :project_id => @project, :id => @board } : |
|
107 | 107 | { :action => 'show', :id => @message.parent, :r => @message } |
|
108 | 108 | end |
|
109 | ||
|
109 | ||
|
110 | 110 | def quote |
|
111 | 111 | user = @message.author |
|
112 | 112 | text = @message.content |
@@ -123,14 +123,14 class MessagesController < ApplicationController | |||
|
123 | 123 | page << "$('message_content').scrollTop = $('message_content').scrollHeight - $('message_content').clientHeight;" |
|
124 | 124 | } |
|
125 | 125 | end |
|
126 | ||
|
126 | ||
|
127 | 127 | def preview |
|
128 | 128 | message = @board.messages.find_by_id(params[:id]) |
|
129 | 129 | @attachements = message.attachments if message |
|
130 | 130 | @text = (params[:message] || params[:reply])[:content] |
|
131 | 131 | render :partial => 'common/preview' |
|
132 | 132 | end |
|
133 | ||
|
133 | ||
|
134 | 134 | private |
|
135 | 135 | def find_message |
|
136 | 136 | find_board |
@@ -139,7 +139,7 private | |||
|
139 | 139 | rescue ActiveRecord::RecordNotFound |
|
140 | 140 | render_404 |
|
141 | 141 | end |
|
142 | ||
|
142 | ||
|
143 | 143 | def find_board |
|
144 | 144 | @board = Board.find(params[:board_id], :include => :project) |
|
145 | 145 | @project = @board.project |
General Comments 0
You need to be logged in to leave comments.
Login now