diff --git a/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb b/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb index 8fee558..3be8c57 100644 --- a/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb +++ b/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb @@ -19,4 +19,15 @@ class CommentGroupPluginProfileController < ProfileController 3 end + include CommentGroupPlugin::CommentsReport + + def export_comments + article_id = params[:id] + article = profile.articles.find(article_id) + result = export_comments_csv(article) + filename = "comments_for_article#{article_id}_#{DateTime.now.to_i}.csv" + send_data result, + :type => 'text/csv; charset=UTF-8; header=present', + :disposition => "attachment; filename=#{filename}" + end end diff --git a/plugins/comment_group/lib/comment_group_plugin.rb b/plugins/comment_group/lib/comment_group_plugin.rb index 51f453e..bd90b97 100644 --- a/plugins/comment_group/lib/comment_group_plugin.rb +++ b/plugins/comment_group/lib/comment_group_plugin.rb @@ -28,7 +28,17 @@ class CommentGroupPlugin < Noosfero::Plugin true end - + def article_extra_toolbar_buttons(article) + user = context.send :user + return [] if !article.comment_group_plugin_enabled? || !article.allow_edit?(user) + [ + { + :title => _('Export Comments'), + :url => {:controller => 'comment_group_plugin_profile', :profile => article.profile.identifier, :action => 'export_comments', :id => article.id}, + :icon => :toggle_comment_paragraph + } + ] + end end require_dependency 'comment_group_plugin/macros/allow_comment' -- libgit2 0.21.2