email_article_plugin_myprofile_controller.rb
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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]
# self.members
def send_email
puts "ID ***************************"
y params[:id]
puts "END ID ***************************"
profile = Profile[params[:profile]]
article = Article.find(params[:id])
session[:notice] = 'Tudo beleza'
EmailArticlePluginMyprofileController::Sender.deliver_mail(article)
#
# puts "########################params[:mailing]########################"
# y params[:mailing]
# raise
#
end
class Sender < ActionMailer::Base
def mail(article)
members = article.profile.members
emails = []
members.each{ |m|
emails.push(m.user.email)
}
puts "***************************"
y emails
puts "***************************"
content_type 'text/html'
recipients emails
from "#{article.author.user.name} <#{article.author.user.email}>"
reply_to article.author.user.email
# if contact.sender
# headers 'X-Noosfero-Sender' => contact.sender.identifier
# end
# if contact.receive_a_copy
# cc "#{@article.author.user.name} <#{@article.author.user.email}>"
# end
subject "[Artigo] " + article.title
body article.body
end
end
# def deliver
# #return false unless self.valid?
# EmailArticlePluginMyprofileController::Sender.deliver_mail(self)
# end
#
# class Sender < ActionMailer::Base
# def mail(contact)
# content_type 'text/html'
# emails = contact.dest.notification_emails
# recipients emails
# from "#{contact.name} <#{contact.dest.environment.noreply_email}>"
# reply_to contact.email
# if contact.sender
# headers 'X-Noosfero-Sender' => contact.sender.identifier
# end
# if contact.receive_a_copy
# cc "#{contact.name} <#{contact.email}>"
# end
# subject "[#{contact.dest.short_name(30)}] " + contact.subject
# body :name => contact.name,
# :email => contact.email,
# :city => contact.city,
# :state => contact.state,
# :message => contact.message,
# :environment => contact.dest.environment.name,
# :url => url_for(:host => contact.dest.environment.default_hostname, :controller => 'home'),
# :target => contact.dest.name
# end
# end
end
#append_view_path File.join(File.dirname(__FILE__) + '/../views')