Class Notifier
In: app/models/notifier.rb
Parent: ActionMailer::Base

Methods

Public Instance methods

[Source]

     # File app/models/notifier.rb, line 176
176:   def authorisation_problem(user, session, params, env)
177:     user = User.new(:name => 'Unknown', :email => 'Unknown') if user.nil?
178:     content_type 'text/html' 
179:     @body['admin']     = User.find_central_admin 
180:     @recipients         = email_addresses_4_report(@body['admin'])
181:     @from               = ENV['EPFWIKI_REPLY_ADDRESS']
182:     @subject            = "[#{ENV['EPFWIKI_APP_NAME']}] Autorisation Problem Detected"
183:     @body['session']    = session
184:     @body['params']     = params
185:     @body['env']        = env
186:     @body['subject']    = @subject
187:     @body['user']       = user
188:   end

[Source]

     # File app/models/notifier.rb, line 164
164:   def contributions_processed(user, contributions)
165:     @recipients = email_addresses_4_report(user)
166:     content_type "text/html" 
167:     @body['contributions'] = contributions
168:     @body['admin'] = User.find_central_admin
169:     @body['user'] = user
170:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
171:     @bcc = email_addresses_4_report(@body['admin'])
172:     @subject = "[#{ENV['EPFWIKI_APP_NAME']}] Your contribution has been processed"
173:     @body['subject'] = @subject
174:   end

TODO replace with notification

[Source]

     # File app/models/notifier.rb, line 151
151:   def email(theUsers, theSubject, theFilePaths, theText, cc = nil)
152:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
153:     @cc = email_addresses_4_report(cc) unless cc.nil?
154:     content_type "text/html" 
155:     @subject = "[" + ENV['EPFWIKI_APP_NAME'] + "] " + theSubject
156:     @recipients = email_addresses_4_report(theUsers)
157:     @body['text'] = theText
158:     @body['admin'] = User.find_central_admin
159:     for filePath  in theFilePaths
160:       attachment :content_type => "application/zip",   :body => File.open(filePath, "rb") {|io| io.read}, :filename => filePath.split("/").last
161:     end
162:   end

[Source]

     # File app/models/notifier.rb, line 116
116:   def env_to(user, session, params, env, sent_on = Time.now)
117:     content_type "text/html" 
118:     @recipients         = user.email
119:     @from               = ENV['EPFWIKI_REPLY_ADDRESS']
120:     @subject            = "[" + ENV['EPFWIKI_APP_NAME'] + "] " + params[:action]
121:     @sent_on            = sent_on
122:     @body["session"]    = session
123:     @body["params"]     = params
124:     @body["env"]        = env
125:   end

[Source]

    # File app/models/notifier.rb, line 42
42:   def error_report(exception, trace, session, params, env, sent_on = Time.now)
43:     content_type "text/html" 
44:     @recipients         = [User.find_central_admin.email, "onno.van.der.straaten@logica.com"]
45:     @from               = ENV['EPFWIKI_REPLY_ADDRESS']
46:     @subject            = "[Error] exception in #{env['REQUEST_URI']}" 
47:     @sent_on            = sent_on
48:     @body["exception"]  = exception
49:     @body["trace"]      = trace
50:     @body["session"]    = session
51:     @body["params"]     = params
52:     @body["env"]        = env
53:   end

[Source]

     # File app/models/notifier.rb, line 190
190:   def feedback(feedback)
191:     content_type 'text/html' 
192:     @body['admin']     = User.find_central_admin 
193:     @recipients         = email_addresses_4_report(@body['admin'])
194:     @from               = ENV['EPFWIKI_REPLY_ADDRESS']
195:     @subject            = "[#{ENV['EPFWIKI_APP_NAME']}] Feedback Posted"
196:     @body['subject']    = @subject
197:     @body['feedback']   = feedback
198:     @body['anywiki']    = Wiki.find(:first, :conditions => ['obsolete_on is null'])
199:   end

[Source]

    # File app/models/notifier.rb, line 31
31:   def lost_password(user, urls)
32:     content_type "text/html"
33:     @recipients = user.email
34:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
35:     @subject = "[" + ENV['EPFWIKI_APP_NAME'] + "] New Password"
36:     @body['user'] = user
37:     @body['admin'] = User.find_central_admin
38:     @body['cnt'] = User.count
39:     @body['urls'] = urls
40:   end

[Source]

     # File app/models/notifier.rb, line 138
138:   def notification(theUsers, subject, introduction, text, request_host = ENV['EPFWIKI_HOST'])
139:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
140:     content_type "text/html" 
141:     @subject = "[#{ENV['EPFWIKI_APP_NAME']}] #{subject}" 
142:     @bcc = email_addresses_4_report(theUsers)
143:     @body['link'] = "<a href=\"http://#{request_host}/users/account\">#{ENV['EPFWIKI_APP_NAME']}</a>"
144:     @body['introduction'] = introduction
145:     @body['text'] = text
146:     @body['admin'] = User.find_central_admin
147:     @body['subject'] = @subject
148:   end

[Source]

     # File app/models/notifier.rb, line 127
127:   def site_status(update, subject)
128:     content_type "text/html" 
129:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
130:     @body['admin'] = User.find_central_admin
131:     @subject =  "[#{ENV['EPFWIKI_APP_NAME']}] #{subject}"
132:     @body['subject'] = @subject
133:     @recipients = update.user.email
134:     @cc = @body['admin'].email
135:     @body['update'] = update
136:   end

[Source]

     # File app/models/notifier.rb, line 55
 55:   def summary(params, runtime = Time.now)
 56:     content_type "text/html" 
 57:     
 58:     case params[:type]
 59:     when 'D' # daily
 60:       starttime = (runtime - 1.day).at_beginning_of_day
 61:       endtime = runtime.at_beginning_of_day
 62:       @bcc = email_addresses_4_report(User.find_all_by_notify_daily(1))
 63:       subject_text = 'Daily'
 64:     when 'W' # weekly
 65:       starttime = (runtime - 1.week).at_beginning_of_week
 66:       endtime = runtime.at_beginning_of_week
 67:       @bcc = email_addresses_4_report(User.find_all_by_notify_weekly(1))
 68:       subject_text = 'Weekly'
 69:     when 'M' # monthly
 70:       starttime = (runtime - 1.month).at_beginning_of_month
 71:       endtime = runtime.at_beginning_of_month
 72:       @bcc = email_addresses_4_report(User.find_all_by_notify_monthly(1))
 73:       subject_text = 'Monthly'
 74:     else
 75:       raise 'Report type is required'
 76:     end
 77:     
 78:     @bcc = email_addresses_4_report(params[:user]) unless params[:user].blank?
 79:     @subject = "[#{ENV['EPFWIKI_APP_NAME']}] #{subject_text} Summary" 
 80: 
 81:     items = UserVersion.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ]) +
 82:     Comment.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ]) +
 83:     Upload.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ]) +
 84:     Wiki.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ])+
 85:     Update.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ]) +
 86:     User.find(:all, :conditions => ['created_on > ? and created_on < ?', starttime, endtime ]) +
 87:     WikiPage.find(:all, :conditions => ['created_on > ? and created_on < ? and tool=?', starttime, endtime, 'Wiki'])
 88:     Checkout.find(:all)
 89:     items.sort_by {|item|item.created_on}
 90:     @body['wikis'] = []
 91:     items.each do |item|
 92:       logger.debug("item: #{item.inspect}")
 93:       w = nil
 94:       case item.class.name
 95:       when Comment.name then w = item.site
 96:       when Wiki.name then w = item
 97:       when Update.name then w = item.wiki
 98:       when Checkout.name then w = item.site
 99:       when Version.name then w = item.wiki
100:       end
101:       @body['wikis'] << w if !w.nil?
102:     end
103:     @body['wikis'] = @body['wikis'].uniq    
104:     @from               = ENV['EPFWIKI_REPLY_ADDRESS']
105:     @sent_on            = Time.now
106:     @body['runtime']    = runtime
107:     @body['endtime']    = endtime
108:     @body['starttime']  = starttime
109:     @body['contributions']   = items
110:     @body['subject']    = subject
111:     @body['admin']      = User.find_central_admin
112:     @body['host']       = ENV['EPFWIKI_HOST']
113:     @body['items'] = items
114:   end

[Source]

    # File app/models/notifier.rb, line 19
19:   def welcome_pw_confirmationlink(user, request_host = ENV['EPFWIKI_HOST'])
20:     content_type "text/html"
21:     @recipients = user.email
22:     @from = ENV['EPFWIKI_REPLY_ADDRESS']
23:     @subject =  "[" + ENV['EPFWIKI_APP_NAME'] + "] Welcome" 
24:     @body['user'] = user
25:     @body['admin'] = User.find_central_admin
26:     @body['subject'] = @subject
27:     @body['request_host'] = request_host
28:   end

[Validate]