Mercurial > hg > soundsoftware-site
diff app/controllers/messages_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 513646585e45 |
children | 5f33065ddc4b |
line wrap: on
line diff
--- a/app/controllers/messages_controller.rb Fri Feb 24 18:36:29 2012 +0000 +++ b/app/controllers/messages_controller.rb Fri Feb 24 19:09:32 2012 +0000 @@ -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 @@ 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 @@ 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 @@ 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 @@ { :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 @@ -115,7 +115,7 @@ content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> " content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n" render(:update) { |page| - page << "$('reply_subject').value = \"#{subject}\";" + page << "$('message_subject').value = \"#{subject}\";" page.<< "$('message_content').value = \"#{content}\";" page.show 'reply' page << "Form.Element.focus('message_content');" @@ -123,14 +123,14 @@ 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 @@ rescue ActiveRecord::RecordNotFound render_404 end - + def find_board @board = Board.find(params[:board_id], :include => :project) @project = @board.project