diff --git a/app/views/content_viewer/_article_toolbar.rhtml b/app/views/content_viewer/_article_toolbar.rhtml index b36ffa3..0da98d7 100644 --- a/app/views/content_viewer/_article_toolbar.rhtml +++ b/app/views/content_viewer/_article_toolbar.rhtml @@ -37,6 +37,11 @@ <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new) %> <% end %> + <% + @plugins.dispatch(:article_toolbar_extra_buttons).each do |plugin_button| %> + <%= instance_eval(&plugin_button) %> + <% end %> + <% if @page.accept_uploads? && @page.allow_create?(user) %> <%= button('upload-file', _('Upload files'), profile.admin_url.merge(:controller => 'cms', :action => 'upload_files', :parent_id => (@page.folder? ? @page : @page.parent))) unless remove_content_button(:upload)%> <% end %> diff --git a/config/plugins/email_article b/config/plugins/email_article new file mode 120000 index 0000000..e431db0 --- /dev/null +++ b/config/plugins/email_article @@ -0,0 +1 @@ +/home/93274300500/projetos/noosfero/plugins/email_article \ No newline at end of file diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 9b9d226..0a86fb8 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -285,6 +285,17 @@ class Noosfero::Plugin nil end + + # -> Adds buttons to manage members page + # returns = { :title => title, :icon => icon, :url => url } + # title = name that will be displayed. + # icon = css class name (for customized icons include them in a css file). + # url = url or route to which the button will redirect. + def article_toolbar_extra_buttons + nil + end + + # This method will be called just before a comment is saved to the database. # # It can modify the comment in several ways. In special, a plugin can call diff --git a/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb b/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb new file mode 100644 index 0000000..c606668 --- /dev/null +++ b/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb @@ -0,0 +1,29 @@ +class EmailArticlePluginMyprofileController < MyProfileController + + needs_profile +# before_filter :check_access_to_profile, :except => [:join, :join_not_logged, :index, :add] +# before_filter :store_location, :only => [:join, :join_not_logged, :report_abuse, :send_mail] +# before_filter :login_required, :only => [:add, :join, :join_not_logged, :leave, :unblock, :leave_scrap, :remove_scrap, :remove_activity, :view_more_activities, :view_more_network_activities, :report_abuse, :register_report, :leave_comment_on_activity, :send_mail] + + def send_email + article = Article.find(params[:id]) + EmailArticlePluginMyprofileController::Sender.deliver_mail(article) + render :text=>'ok' + end + + class Sender < ActionMailer::Base + def mail(article) + members = article.profile.members + emails = [] + members.each{ |m| + emails.push(m.user.email) + } + content_type 'text/html' + recipients emails + from "#{article.author.user.name} <#{article.author.user.email}>" + reply_to article.author.user.email + subject "[Artigo] " + article.title + body article.body + end + end +end \ No newline at end of file diff --git a/plugins/email_article/lib/email_article_plugin.rb b/plugins/email_article/lib/email_article_plugin.rb new file mode 100644 index 0000000..1548508 --- /dev/null +++ b/plugins/email_article/lib/email_article_plugin.rb @@ -0,0 +1,30 @@ +class EmailArticlePlugin < Noosfero::Plugin + + def self.plugin_name + "Email Article to Community Members Plugin" + end + + def self.plugin_description + _("A plugin that emails an article to the members of the community.") + end + + def article_toolbar_extra_buttons + label = _("Send article to members") + htmlclass = _("button with-text icon-menu-mail") + title = _("Email article to all community members") + lambda { + link_to_remote( + label, + { + :url => { :controller => 'email_article_plugin_myprofile', :action => "send_email", :id => @page}, + :method => :get, + :success => "alert('Emails enviados')", + :failure => "alert('Erro ao enviar email')", + :confirm => _("Are you sure you want to email this article to the all community members?"), + }, + :class => htmlclass, + :title => title + ) + } + end +end diff --git a/plugins/email_article/test/test_helper.rb b/plugins/email_article/test/test_helper.rb new file mode 100644 index 0000000..cca1fd3 --- /dev/null +++ b/plugins/email_article/test/test_helper.rb @@ -0,0 +1 @@ +require File.dirname(__FILE__) + '/../../../test/test_helper' diff --git a/plugins/email_article/test/unit/email_article_plugin_test.rb b/plugins/email_article/test/unit/email_article_plugin_test.rb new file mode 100644 index 0000000..f5d94eb --- /dev/null +++ b/plugins/email_article/test/unit/email_article_plugin_test.rb @@ -0,0 +1,21 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class EmailArticlePluginTest < ActiveSupport::TestCase + + def setup + @plugin = EmailArticlePlugin.new + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'have name' do + assert_equal 'Relevant Content Plugin', EmailArticlePlugin.plugin_name + end + + should 'have description' do + assert_equal _("A plugin that lists the most accessed, most commented, most liked and most disliked contents."), EmailArticlePlugin.plugin_description + end + +end -- libgit2 0.21.2