2014-03-09 14:43:33 -06:00
class UserMailer < ActionMailer :: Base
2015-08-18 22:18:29 -07:00
add_template_helper ( ApplicationHelper )
2015-09-07 12:25:17 -07:00
include LinguaFrancaHelper
2014-07-24 00:16:33 -06:00
default from : " Bike!Bike! <noreply@bikebike.org> "
2014-03-09 14:43:33 -06:00
2014-07-18 20:35:15 -06:00
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.user_mailer.activation_needed_email.subject
#
def activation_needed_email ( email_address )
@greeting = " Hi "
2014-03-09 14:43:33 -06:00
2015-04-01 18:02:51 -07:00
mail to : email_address
2014-07-18 20:35:15 -06:00
end
2014-03-09 14:43:33 -06:00
2014-07-18 20:35:15 -06:00
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.user_mailer.activation_success_email.subject
#
def activation_success_email
@greeting = " Hi "
2014-03-09 14:43:33 -06:00
2014-07-18 20:35:15 -06:00
mail to : " to@example.org "
end
2015-04-14 19:41:46 -07:00
def test_email
2015-08-04 21:54:04 -07:00
mail to : 'goodgodwin@hotmail.com' , subject : 'This is a test' , from : 'info@preview.bikebike.org'
2015-04-14 19:41:46 -07:00
end
2014-07-24 00:16:33 -06:00
def conference_registration_email ( conference , data , conference_registration )
@data = data
@conference = conference
@url = " https://bikebike.org " #UserMailer.default_url_options[:host]
@confirmation_url = UserMailer . default_url_options [ :host ] + " / #{ @conference . url } /register/confirm/ #{ conference_registration . confirmation_token } / " . gsub ( / \/ \/ + / , '/' )
2015-08-04 21:54:04 -07:00
mail to : data [ :email ] , subject : ( I18n . t 'register.email.registration.subject' , " Please confirm your registration for #{ conference . title } " , vars : { :conference_title = > conference . title } )
2014-07-24 00:16:33 -06:00
end
def conference_registration_confirmed_email ( conference , data , conference_registration )
2014-07-18 20:35:15 -06:00
@data = data
@conference = conference
2014-07-24 00:16:33 -06:00
@url = " https://bikebike.org " #UserMailer.default_url_options[:host]
@confirmation_url = UserMailer . default_url_options [ :host ] + " / #{ @conference . url } /register/pay-registration/ #{ conference_registration . confirmation_token } / " . gsub ( / \/ \/ + / , '/' )
2015-08-04 21:54:04 -07:00
mail to : data [ :email ] , subject : ( I18n . t 'register.email.registration_confirmed.subject' , " Thanks for confirming your registration for #{ conference . title } " , vars : { :conference_title = > conference . title } )
end
def email_confirmation ( confirmation )
@confirmation = confirmation
@host = UserMailer . default_url_options [ :host ]
mail to : confirmation . user . email ,
2015-09-07 12:25:17 -07:00
subject : ( _ 'email.subject.confirm_email' , 'Please confirm your email address' )
2014-07-18 20:35:15 -06:00
end
2015-08-18 22:18:29 -07:00
2015-09-11 17:31:14 -07:00
def registration_confirmation ( registration )
@host = UserMailer . default_url_options [ :host ]
@registration = registration
@conference = Conference . find ( @registration . conference_id )
@user = User . find ( @registration . user_id )
mail to : @user . email ,
subject : _ ( 'email.subject.registration_confirmed' ,
" Thank you for registering for #{ @conference . title } " ,
:vars = > { :conference_title = > @conference . title } )
end
2015-08-18 22:18:29 -07:00
def broadcast ( host , subject , content , user , conference )
@host = host
@content = content
2015-09-27 21:27:31 -07:00
@banner = nil #(@host || 'http://localhost/') + (conference ? (conference.poster.preview.url || '') : image_url('logo.png'))
2015-08-18 22:18:29 -07:00
if user && user . email
2015-09-27 21:27:31 -07:00
email = user . email
2015-09-27 21:15:43 -07:00
mail to : email , subject : " [ #{ conference ? conference . title : 'Bike!Bike!' } ] #{ subject } "
2015-08-18 22:18:29 -07:00
end
end
2015-09-19 16:30:39 -07:00
def workshop_facilitator_request ( workshop , requester , message )
@host = UserMailer . default_url_options [ :host ]
@workshop = workshop
@requester = requester
addresses = [ ]
@workshop . active_facilitators . each do | f |
addresses << f . email
end
@message = message
@conference = Conference . find ( @workshop . conference_id )
mail to : addresses ,
from : @requester . email ,
subject : _ ( 'email.subject.workshop_facilitator_request' ,
" Request to facilitate #{ @workshop . title } from #{ @requester . firstname } " ,
:vars = > { :workshop_title = > @workshop . title , :requester_name = > @requester . firstname } )
end
def workshop_facilitator_request_approved ( workshop , user )
@host = UserMailer . default_url_options [ :host ]
@workshop = workshop
@conference = Conference . find ( @workshop . conference_id )
@user = user
mail to : user . email ,
subject : ( _ 'email.subject.workshop_request_approved' ,
" You have been added as a facilitator of #{ @workshop . title } " ,
:vars = > { :workshop_title = > @workshop . title } )
end
def workshop_facilitator_request_denied ( workshop , user )
@host = UserMailer . default_url_options [ :host ]
@workshop = workshop
@conference = Conference . find ( @workshop . conference_id )
@user = user
mail to : user . email ,
subject : ( _ 'email.subject.workshop_request_denied' ,
" Your request to facilitate #{ @workshop . title } has been denied " ,
:vars = > { :workshop_title = > @workshop . title } )
end
2014-03-09 14:43:33 -06:00
end