Class: ODDB::State::User::MailingList

Inherits:
Global show all
Defined in:
src/state/user/mailinglist.rb

Constant Summary

VIEW =
View::User::MailingList
DIRECT_EVENT =
:mailinglist

Constants inherited from Global

HOME_STATE, ZONE, ZONE_NAVIGATION

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Method Summary (collapse)

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from Admin::LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Method Details

- (Object) send_email(subscriber, recipient, info_message)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'src/state/user/mailinglist.rb', line 31

def send_email(subscriber, recipient, info_message)
  mail = TMail::Mail.new
  mail.from = subscriber 
  mail.to = recipient
  mail.date = Time.now
  begin
    config = ODDB.config
    Net::SMTP.start(config.smtp_server, config.smtp_port, config.smtp_domain,
                    config.smtp_user, config.smtp_pass,
                    config.smtp_authtype) { |smtp|
      smtp.sendmail(mail.encoded, subscriber, recipient)
    }
    @infos.push(info_message)
  rescue
    @errors.store(:mailinglist_email, create_error('e_subscriber_mail_notsent', :mailinglist_email, subscriber))
  end
end

- (Object) update



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'src/state/user/mailinglist.rb', line 15

def update
  if(@session.user_input(:subscribe))
    recipient = 'news-subscribe@generika.cc'
    info_message = :i_subscriber_mail_sent
  elsif(@session.user_input(:unsubscribe))
    recipient = 'news-unsubscribe@generika.cc'
    info_message = :i_unsubscriber_mail_sent
  end
   = @session.user_input(:email)
  unless(.is_a?(SBSM::InvalidDataError))
    send_email(, recipient, info_message)
  else
    @errors.store(:mailinglist_email, create_error(.message, :mailinglist_email, .value))
  end
  self 
end