]> projects.mako.cc - selectricity/blob - vendor/plugins/login_engine/app/models/user_notify.rb
Added the RoR Login-Engine and activated it on the site.
[selectricity] / vendor / plugins / login_engine / app / models / user_notify.rb
1 class UserNotify < ActionMailer::Base
2   def signup(user, password, url=nil)
3     setup_email(user)
4
5     # Email header info
6     @subject += "Welcome to #{LoginEngine.config(:app_name)}!"
7
8     # Email body substitutions
9     @body["name"] = "#{user.firstname} #{user.lastname}"
10     @body["login"] = user.login
11     @body["password"] = password
12     @body["url"] = url || LoginEngine.config(:app_url).to_s
13     @body["app_name"] = LoginEngine.config(:app_name).to_s
14   end
15
16   def forgot_password(user, url=nil)
17     setup_email(user)
18
19     # Email header info
20     @subject += "Forgotten password notification"
21
22     # Email body substitutions
23     @body["name"] = "#{user.firstname} #{user.lastname}"
24     @body["login"] = user.login
25     @body["url"] = url || LoginEngine.config(:app_url).to_s
26     @body["app_name"] = LoginEngine.config(:app_name).to_s
27   end
28
29   def change_password(user, password, url=nil)
30     setup_email(user)
31
32     # Email header info
33     @subject += "Changed password notification"
34
35     # Email body substitutions
36     @body["name"] = "#{user.firstname} #{user.lastname}"
37     @body["login"] = user.login
38     @body["password"] = password
39     @body["url"] = url || LoginEngine.config(:app_url).to_s
40     @body["app_name"] = LoginEngine.config(:app_name).to_s
41   end
42
43   def pending_delete(user, url=nil)
44     setup_email(user)
45
46     # Email header info
47     @subject += "Delete user notification"
48
49     # Email body substitutions
50     @body["name"] = "#{user.firstname} #{user.lastname}"
51     @body["url"] = url || LoginEngine.config(:app_url).to_s
52     @body["app_name"] = LoginEngine.config(:app_name).to_s
53     @body["days"] = LoginEngine.config(:delayed_delete_days).to_s
54   end
55
56   def delete(user, url=nil)
57     setup_email(user)
58
59     # Email header info
60     @subject += "Delete user notification"
61
62     # Email body substitutions
63     @body["name"] = "#{user.firstname} #{user.lastname}"
64     @body["url"] = url || LoginEngine.config(:app_url).to_s
65     @body["app_name"] = LoginEngine.config(:app_name).to_s
66   end
67
68   def setup_email(user)
69     @recipients = "#{user.email}"
70     @from       = LoginEngine.config(:email_from).to_s
71     @subject    = "[#{LoginEngine.config(:app_name)}] "
72     @sent_on    = Time.now
73     @headers['Content-Type'] = "text/plain; charset=#{LoginEngine.config(:mail_charset)}; format=flowed"
74   end
75 end

Benjamin Mako Hill || Want to submit a patch?