diff options
-rw-r--r-- | app/controllers/messages_controller.rb | 16 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 6 | ||||
-rw-r--r-- | app/views/messages/show.rhtml | 2 | ||||
-rw-r--r-- | lang/bg.yml | 1 | ||||
-rw-r--r-- | lang/cs.yml | 1 | ||||
-rw-r--r-- | lang/da.yml | 1 | ||||
-rw-r--r-- | lang/de.yml | 1 | ||||
-rw-r--r-- | lang/en.yml | 1 | ||||
-rw-r--r-- | lang/es.yml | 1 | ||||
-rw-r--r-- | lang/fi.yml | 1 | ||||
-rw-r--r-- | lang/fr.yml | 1 | ||||
-rw-r--r-- | lang/he.yml | 1 | ||||
-rw-r--r-- | lang/hu.yml | 1 | ||||
-rw-r--r-- | lang/it.yml | 1 | ||||
-rw-r--r-- | lang/ja.yml | 1 | ||||
-rw-r--r-- | lang/ko.yml | 1 | ||||
-rw-r--r-- | lang/lt.yml | 1 | ||||
-rw-r--r-- | lang/nl.yml | 1 | ||||
-rw-r--r-- | lang/no.yml | 1 | ||||
-rw-r--r-- | lang/pl.yml | 1 | ||||
-rw-r--r-- | lang/pt-br.yml | 1 | ||||
-rw-r--r-- | lang/pt.yml | 1 | ||||
-rw-r--r-- | lang/ro.yml | 1 | ||||
-rw-r--r-- | lang/ru.yml | 1 | ||||
-rw-r--r-- | lang/sr.yml | 1 | ||||
-rw-r--r-- | lang/sv.yml | 1 | ||||
-rw-r--r-- | lang/th.yml | 1 | ||||
-rw-r--r-- | lang/uk.yml | 1 | ||||
-rw-r--r-- | lang/zh-tw.yml | 1 | ||||
-rw-r--r-- | lang/zh.yml | 1 | ||||
-rw-r--r-- | lib/redmine.rb | 2 | ||||
-rw-r--r-- | public/stylesheets/application.css | 1 | ||||
-rw-r--r-- | test/functional/messages_controller_test.rb | 16 |
33 files changed, 69 insertions, 1 deletions
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 08c77d7d2..554279d21 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ed5c6bdb7..78e5bdc65 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/views/messages/show.rhtml b/app/views/messages/show.rhtml index 7e5975bfd..c24be7a21 100644 --- a/app/views/messages/show.rhtml +++ b/app/views/messages/show.rhtml @@ -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> diff --git a/lang/bg.yml b/lang/bg.yml index f15ba4da7..1f174e29f 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -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 diff --git a/lang/cs.yml b/lang/cs.yml index b7b1b9eaf..609e95478 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -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 diff --git a/lang/da.yml b/lang/da.yml index 3227dc7bd..a76e7ea5c 100644 --- a/lang/da.yml +++ b/lang/da.yml @@ -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 diff --git a/lang/de.yml b/lang/de.yml index 5093c31fd..e309dfb57 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -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 diff --git a/lang/en.yml b/lang/en.yml index 6cd6d4270..5f552774c 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -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 diff --git a/lang/es.yml b/lang/es.yml index 58d27f28d..fc9540a02 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -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 diff --git a/lang/fi.yml b/lang/fi.yml index 394ff23f3..6eb16bfac 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -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 diff --git a/lang/fr.yml b/lang/fr.yml index e6c4b3340..81e44949f 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -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é diff --git a/lang/he.yml b/lang/he.yml index 652b0ed8e..77fe32e53 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -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 diff --git a/lang/hu.yml b/lang/hu.yml index 15c420539..208b6fe1e 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -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 diff --git a/lang/it.yml b/lang/it.yml index 3e1c1d53b..d123e913a 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -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 diff --git a/lang/ja.yml b/lang/ja.yml index e7805393a..5a728fb02 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -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 diff --git a/lang/ko.yml b/lang/ko.yml index c85ce72e2..16bd65364 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -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 diff --git a/lang/lt.yml b/lang/lt.yml index 188faf215..2a75a95ea 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -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 diff --git a/lang/nl.yml b/lang/nl.yml index fd5bff1f6..f79e78994 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -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 diff --git a/lang/no.yml b/lang/no.yml index 2cdc0bcd6..6643f9c86 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -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 diff --git a/lang/pl.yml b/lang/pl.yml index 69e04e4dd..2df921b71 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -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 diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 2b25e023f..8cd171b72 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -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
diff --git a/lang/pt.yml b/lang/pt.yml index 6505b762a..5562ca4ac 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -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 diff --git a/lang/ro.yml b/lang/ro.yml index 4887bcf92..5bb49ecec 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -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 diff --git a/lang/ru.yml b/lang/ru.yml index 095e4db34..01cdcd478 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -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 diff --git a/lang/sr.yml b/lang/sr.yml index f81d0e054..566a46d9f 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -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 diff --git a/lang/sv.yml b/lang/sv.yml index 5e120b3f2..4cb1f073b 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -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 diff --git a/lang/th.yml b/lang/th.yml index 3ae37e551..2c3977de2 100644 --- a/lang/th.yml +++ b/lang/th.yml @@ -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 diff --git a/lang/uk.yml b/lang/uk.yml index cf5f384b9..7ba152413 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -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 diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index f13331df4..6a1441364 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -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 diff --git a/lang/zh.yml b/lang/zh.yml index 07829a541..bfe551093 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -636,3 +636,4 @@ default_activity_development: 开发 enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) +button_quote: Quote diff --git a/lib/redmine.rb b/lib/redmine.rb index 9890ab06f..33d33752b 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -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 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index c7e9284d2..e5ca9e8f2 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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); } diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 1fe8d086a..b1b3ea942 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -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 |