]> source.dussan.org Git - redmine.git/commitdiff
Adds posts quoting functionality (#1825).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 28 Aug 2008 18:56:47 +0000 (18:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 28 Aug 2008 18:56:47 +0000 (18:56 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1772 e93f8b46-1217-0410-a6f0-8f06a7374b81

33 files changed:
app/controllers/messages_controller.rb
app/helpers/application_helper.rb
app/views/messages/show.rhtml
lang/bg.yml
lang/cs.yml
lang/da.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fi.yml
lang/fr.yml
lang/he.yml
lang/hu.yml
lang/it.yml
lang/ja.yml
lang/ko.yml
lang/lt.yml
lang/nl.yml
lang/no.yml
lang/pl.yml
lang/pt-br.yml
lang/pt.yml
lang/ro.yml
lang/ru.yml
lang/sr.yml
lang/sv.yml
lang/th.yml
lang/uk.yml
lang/zh-tw.yml
lang/zh.yml
lib/redmine.rb
public/stylesheets/application.css
test/functional/messages_controller_test.rb

index 08c77d7d2774e9dda14859743bcede6ec2d2a4c9..554279d21261d6708263c98c04c458424518d795 100644 (file)
@@ -22,7 +22,9 @@ class MessagesController < ApplicationController
   before_filter :authorize, :except => :preview
 
   verify :method => :post, :only => [ :reply, :destroy ], :redirect_to => { :action => :show }
+  verify :xhr => true, :only => :quote
 
+  
   helper :attachments
   include AttachmentsHelper   
 
@@ -82,6 +84,20 @@ class MessagesController < ApplicationController
       { :action => 'show', :id => @message.parent }
   end
   
+  def quote
+    user = @message.author
+    text = @message.content
+    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.<< "$('message_content').value = \"#{content}\";"
+      page.show 'reply'
+      page << "Form.Element.focus('message_content');"
+      page << "Element.scrollTo('reply');"
+      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
index ed5c6bdb712b542f3d7a76e55837a44b08873dd8..78e5bdc653255b5031377a9e972dcef2306c9758 100644 (file)
@@ -34,6 +34,12 @@ module ApplicationHelper
   def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
     link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
   end
+  
+  # Display a link to remote if user is authorized
+  def link_to_remote_if_authorized(name, options = {}, html_options = nil)
+    url = options[:url] || {}
+    link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
+  end
 
   # Display a link to user's account page
   def link_to_user(user)
index 7e5975bfd8bd8da6a2599bae6a9ea1277464ed84..c24be7a213bf381ce9d474419ba84528d110d0cf 100644 (file)
@@ -2,6 +2,7 @@
                link_to(h(@board.name), {:controller => 'boards', :action => 'show', :project_id => @project, :id => @board}) %>
 
 <div class="contextual">
+    <%= link_to_remote_if_authorized l(:button_quote), { :url => {:action => 'quote', :id => @topic} }, :class => 'icon icon-comment' %>
     <%= link_to_if_authorized l(:button_edit), {:action => 'edit', :id => @topic}, :class => 'icon icon-edit' %>
     <%= link_to_if_authorized l(:button_delete), {:action => 'destroy', :id => @topic}, :method => :post, :confirm => l(:text_are_you_sure), :class => 'icon icon-del' %>
 </div>
@@ -22,6 +23,7 @@
 <% @replies.each do |message| %>
   <a name="<%= "message-#{message.id}" %>"></a>
   <div class="contextual">
+    <%= link_to_remote_if_authorized image_tag('comment.png'), { :url => {:action => 'quote', :id => message} }, :title => l(:button_quote) %>
     <%= link_to_if_authorized image_tag('edit.png'), {:action => 'edit', :id => message}, :title => l(:button_edit) %>
     <%= link_to_if_authorized image_tag('delete.png'), {:action => 'destroy', :id => message}, :method => :post, :confirm => l(:text_are_you_sure), :title => l(:button_delete) %>
   </div>
index f15ba4da7afa9fcc0ad6e6d94b9c9fccec095fe8..1f174e29fdd6fe0d2a7997cae77a1df674944da9 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index b7b1b9eafe7751f5a9c01d92981bb6b5af75b9cb..609e9547830f932f95803dabd992d15a3a0b01f1 100644 (file)
@@ -640,3 +640,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 3227dc7bd39df1ff77c4aff2097db29821d0e10f..a76e7ea5c1155cd1ca1d14faf17c53487619d49a 100644 (file)
@@ -637,3 +637,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 5093c31fd915c9ce436e92e561efbe69f2842ba9..e309dfb576197f959a82362becc168096a8023bf 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 6cd6d42706ca5a28f9b911dc13f3c143d07d738e..5f552774cf533f61312d342c7bbf33652fb0706a 100644 (file)
@@ -561,6 +561,7 @@ button_copy: Copy
 button_annotate: Annotate
 button_update: Update
 button_configure: Configure
+button_quote: Quote
 
 status_active: active
 status_registered: registered
index 58d27f28d4cee35d871e0bccf064abb8ade85acc..fc9540a02e5de1cbb7dc78cbed9259c731fdfb83 100644 (file)
@@ -638,3 +638,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 394ff23f3c8995c0804e40392e36f25dee138b09..6eb16bfacaa9bf498ff5e9600f16a3b3bb11c173 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index e6c4b33401537dbceb05f18a881d7afb90e5f521..81e44949f945920f2dbd61f30ba454351de8700c 100644 (file)
@@ -561,6 +561,7 @@ button_copy: Copier
 button_annotate: Annoter
 button_update: Mettre à jour
 button_configure: Configurer
+button_quote: Citer
 
 status_active: actif
 status_registered: enregistré
index 652b0ed8e50db14636de885b6ce75c2c1977a6bd..77fe32e53e8aaa060a922ec93d012ac102227c7d 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 15c4205399e3c92c1c9d087e1c8f9894abba3cd9..208b6fe1e1123572978eae57ed846af0a7ac2711 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Az E-mail küldés nincs konfigurálva, és
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 3e1c1d53bb04ca5012461bdb0d1204060eaa308f..d123e913a0a2c9978c161a2f2c667f2a3df7967c 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "La consegna via e-mail non è configurata e
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index e7805393af638797acf9530aab357e89d3cc5f35..5a728fb02c7850d97ae4c8776a5e07f64ec3cafe 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index c85ce72e2be5673f9ca2a7870609bd2ba6edf634..16bd6536462c24c262bd3567aca9432bfd85ff4a 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 188faf215651b2a1917f0a1c4995671cb03ad291..2a75a95ea8449ea02cdb7af57885e6dc5d308fbb 100644 (file)
@@ -638,3 +638,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index fd5bff1f633d2df0207e3ec397711d3143222d99..f79e78994ead2eb09ab1538b2ec3b0d20fd76489 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 2cdc0bcd6b4395f61becb8812c771f47a4ba835a..6643f9c86065a0952858d76331136127c76bd67a 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 69e04e4dda08ce11a18f39cbd345bc12588c8571..2df921b71f6ae89dada9a6101858661be06dd118 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 2b25e023f97b06f04e4401fc9e7bd1a56d9e9c5a..8cd171b729606ceff78d1bc6f4ab359ac9c58ec7 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page\r
 label_issue_watchers: Watchers\r
 setting_commit_logs_encoding: Commit messages encoding\r
+button_quote: Quote\r
index 6505b762a2b2135af3b3e75dfa42ae7ad8ba8bde..5562ca4acd34a9b9f924206b53acbe322850f56c 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 4887bcf928e44cf8e9277307ee308ca09b09c2b3..5bb49ececec8bc5b158b3d5fe83659e0a73cec9a 100644 (file)
@@ -635,3 +635,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 095e4db34014ca0e827917e4abb5e1915736170e..01cdcd47854b6f66ed5c5e68d51970d0933ad7ed 100644 (file)
@@ -639,3 +639,4 @@ text_email_delivery_not_configured: "Параметры работы с почт
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index f81d0e05497e1f5bd8a696bb9ef18fe81453e246..566a46d9fda088b5ff04c282b1eeffc038cb15c1 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 5e120b3f2e32aaeda2c8425c753c48bdf6ce8cb7..4cb1f073b54de2aa94a20eebab1dea24d544c64f 100644 (file)
@@ -636,3 +636,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 3ae37e5515008ad50a63538c9849af65ee6843d2..2c3977de2018b2cebc12c9b2d3333129b73332aa 100644 (file)
@@ -638,3 +638,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index cf5f384b99cbbd1eaa241abbd424c9b9bdfe835f..7ba15241352597d093048c781da31595c313ae31 100644 (file)
@@ -637,3 +637,4 @@ text_email_delivery_not_configured: "Email delivery is not configured, and notif
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index f13331df4afd794682430f749e0569d58d13349f..6a144136452d97c9772941167c3fb5ab21ec3d0f 100644 (file)
@@ -636,3 +636,4 @@ enumeration_activities: 活動 (時間追蹤)
 field_parent_title: Parent page
 label_issue_watchers: Watchers
 setting_commit_logs_encoding: Commit messages encoding
+button_quote: Quote
index 07829a541f55ae5b25d25ad10655d8a851c75e62..bfe5510931bee03be9c3e37e7666b951aa224fbf 100644 (file)
@@ -636,3 +636,4 @@ default_activity_development: 开发
 enumeration_issue_priorities: 问题优先级
 enumeration_doc_categories: 文档类别
 enumeration_activities: 活动(时间跟踪)
+button_quote: Quote
index 9890ab06f4ac62d23407eef300f109db3610c1a6..33d33752b4c59bebd0b8e0d1b4234f2a9969d912 100644 (file)
@@ -92,7 +92,7 @@ Redmine::AccessControl.map do |map|
   map.project_module :boards do |map|
     map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member
     map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true
-    map.permission :add_messages, {:messages => [:new, :reply]}
+    map.permission :add_messages, {:messages => [:new, :reply, :quote]}
     map.permission :edit_messages, {:messages => :edit}, :require => :member
     map.permission :delete_messages, {:messages => :destroy}, :require => :member
   end
index c7e9284d2f195c868ab79c67a13d26146dc4dde7..e5ca9e8f2411961750f10f04f43b6f59363176e6 100644 (file)
@@ -599,6 +599,7 @@ vertical-align: middle;
 .icon-checked  { background-image: url(../images/true.png); }
 .icon-details  { background-image: url(../images/zoom_in.png); }
 .icon-report  { background-image: url(../images/report.png); }
+.icon-comment  { background-image: url(../images/comment.png); }
 
 .icon22-projects { background-image: url(../images/22x22/projects.png); }
 .icon22-users { background-image: url(../images/22x22/users.png); }
index 1fe8d086a877d3c488cf3317368c6c376c9cefc3..b1b3ea94258739d60b7e6c12e44153124fa1fee9 100644 (file)
@@ -40,6 +40,15 @@ class MessagesControllerTest < Test::Unit::TestCase
     assert_not_nil assigns(:topic)
   end
   
+  def test_show_with_reply_permission
+    @request.session[:user_id] = 2
+    get :show, :board_id => 1, :id => 1
+    assert_response :success
+    assert_template 'show'
+    assert_tag :div, :attributes => { :id => 'reply' },
+                     :descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } }
+  end
+  
   def test_show_message_not_found
     get :show, :board_id => 1, :id => 99999
     assert_response 404
@@ -108,4 +117,11 @@ class MessagesControllerTest < Test::Unit::TestCase
     assert_redirected_to 'boards/show'
     assert_nil Message.find_by_id(1)
   end
+  
+  def test_quote
+    @request.session[:user_id] = 2
+    xhr :get, :quote, :board_id => 1, :id => 3
+    assert_response :success
+    assert_select_rjs :show, 'reply'
+  end
 end