Class: Orange::ContactFormsResource
- Inherits:
-
ModelResource
- Object
- ModelResource
- Orange::ContactFormsResource
- Defined in:
- lib/orange-more/contactforms/resources/contactforms_resource.rb
Instance Method Summary collapse
Instance Method Details
#contactform(packet, opts = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/orange-more/contactforms/resources/contactforms_resource.rb', line 29 def contactform(packet, opts = {}) template = opts[:template].to_sym || :contactform packet['route.return_path'] = packet.request.path.to_s do_view(packet, template, opts) end |
#mailer(packet, opts = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/orange-more/contactforms/resources/contactforms_resource.rb', line 35 def mailer(packet, opts = {}) params = packet.request.params route = params['r'] # The contact phone number is a honeypot field. if params['contact_phone'] != '' || params['contact_from'].blank? || params['contact_email_address'].blank? packet.flash['error'] = "An error has occurred. Please try your submission again." packet.reroute(route) end path = packet['route.resource_path'] parts = path.split('/') form = model_class.get(parts.last.to_i) mail = Mail.new do from "#{packet['site'].name} <#{form.from_address}>" to form.to_address subject "E-mail contact from #{packet['site'].name}" body "From: "+params['contact_from']+" ("+params['contact_email_address']+")\n\nMessage:\n"+params['contact_message'] end mail.delivery_method :sendmail mail.deliver packet.flash['error'] = "Thanks for your submission. We will contact you as soon as possible." packet.reroute(route) end |
#stack_init ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/orange-more/contactforms/resources/contactforms_resource.rb', line 8 def stack_init orange[:admin, true].add_link("Content", :resource => @my_orange_name, :text => 'Contact Forms') orange[:radius].define_tag "contactform" do |tag| if tag.attr["name"] && model_class.named(tag.attr["name"]).count >0 m = model_class.named(tag.attr["name"]).first #selects contactform based on title elsif model_class.all.count > 0 if tag.attr["id"] m = model_class.get(tag.attr["id"]) else m = model_class.first end end unless m.nil? template = tag.attr["template"] || "contactform" orange[:contactforms].contactform(tag.locals.packet, {:model => m, :template => template, :id => m.id}) else "" end end end |