Mercurial > hg > soundsoftware-site
comparison app/controllers/messages_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
| author | Chris Cannam |
|---|---|
| date | Fri, 14 Jun 2013 09:28:30 +0100 |
| parents | 622f24f53b42 |
| children |
comparison
equal
deleted
inserted
replaced
| 1297:0a574315af3e | 1298:4f746d8966dd |
|---|---|
| 1 # Redmine - project management software | 1 # Redmine - project management software |
| 2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
| 3 # | 3 # |
| 4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
| 5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
| 6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
| 7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
| 17 | 17 |
| 18 class MessagesController < ApplicationController | 18 class MessagesController < ApplicationController |
| 19 menu_item :boards | 19 menu_item :boards |
| 20 default_search_scope :messages | 20 default_search_scope :messages |
| 21 before_filter :find_board, :only => [:new, :preview] | 21 before_filter :find_board, :only => [:new, :preview] |
| 22 before_filter :find_attachments, :only => [:preview] | |
| 22 before_filter :find_message, :except => [:new, :preview] | 23 before_filter :find_message, :except => [:new, :preview] |
| 23 before_filter :authorize, :except => [:preview, :edit, :destroy] | 24 before_filter :authorize, :except => [:preview, :edit, :destroy] |
| 24 | 25 |
| 25 helper :boards | 26 helper :boards |
| 26 helper :watchers | 27 helper :watchers |
| 37 offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) | 38 offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) |
| 38 page = 1 + offset / REPLIES_PER_PAGE | 39 page = 1 + offset / REPLIES_PER_PAGE |
| 39 end | 40 end |
| 40 | 41 |
| 41 @reply_count = @topic.children.count | 42 @reply_count = @topic.children.count |
| 42 @reply_pages = Paginator.new self, @reply_count, REPLIES_PER_PAGE, page | 43 @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page |
| 43 @replies = @topic.children.find(:all, :include => [:author, :attachments, {:board => :project}], | 44 @replies = @topic.children. |
| 44 :order => "#{Message.table_name}.created_on ASC", | 45 includes(:author, :attachments, {:board => :project}). |
| 45 :limit => @reply_pages.items_per_page, | 46 reorder("#{Message.table_name}.created_on ASC"). |
| 46 :offset => @reply_pages.current.offset) | 47 limit(@reply_pages.per_page). |
| 48 offset(@reply_pages.offset). | |
| 49 all | |
| 47 | 50 |
| 48 @reply = Message.new(:subject => "RE: #{@message.subject}") | 51 @reply = Message.new(:subject => "RE: #{@message.subject}") |
| 49 render :action => "show", :layout => false if request.xhr? | 52 render :action => "show", :layout => false if request.xhr? |
| 50 end | 53 end |
| 51 | 54 |
| 113 @content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | 116 @content << @message.content.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" |
| 114 end | 117 end |
| 115 | 118 |
| 116 def preview | 119 def preview |
| 117 message = @board.messages.find_by_id(params[:id]) | 120 message = @board.messages.find_by_id(params[:id]) |
| 118 @attachements = message.attachments if message | |
| 119 @text = (params[:message] || params[:reply])[:content] | 121 @text = (params[:message] || params[:reply])[:content] |
| 120 @previewed = message | 122 @previewed = message |
| 121 render :partial => 'common/preview' | 123 render :partial => 'common/preview' |
| 122 end | 124 end |
| 123 | 125 |
