Changeset 819

Show
Ignore:
Timestamp:
04/18/08 16:18:15 (5 months ago)
Author:
seancribbs
Message:

#637 Fix redirection after POST in mailer extension. [Fabrice Luraine]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/extensions/mailer/app/models/mailer_page.rb

    r803 r819  
    22class MailerPage < Page 
    33  TLDS = %w{com org net edu info mil gov biz ws} 
    4    
     4 
    55  class MailerTagError < StandardError; end 
    66 
     
    1515    end 
    1616  end 
    17      
     17 
    1818  # Page processing. If the page has posted-back, it will try to deliver the emails 
    1919  # and redirect to a different page, if specified. 
     
    2828      if form_conf.has_key? :recipients 
    2929        if send_mail and form_conf.has_key? :redirect_to 
    30           response.redirect( form_conf[:redirect_to],"302"
     30          response.redirect(form_conf[:redirect_to], :status => 302
    3131        else 
    32           super(request, response)  
     32          super(request, response) 
    3333        end 
    3434      else 
     
    4545    false 
    4646  end 
    47    
     47 
    4848  # Mailer Tags: 
    49      
     49 
    5050    desc %{ All mailer-related tags live inside this one. } 
    5151    tag "mailer" do |tag| 
    5252      tag.expand 
    5353    end 
    54      
     54 
    5555    desc %{ 
    5656    Generates a form for submitting email.  The 'name' attribute is required 
     
    7979        raise_error_if_name_missing "mailer:#{type}" unless %(submit reset).include? type 
    8080        input_tag_html( type ) 
    81       end       
     81      end 
    8282    end 
    8383 
     
    105105      results << "</textarea>" 
    106106    end 
    107      
     107 
    108108    %{ 
    109109    Renders a series of @<input type="radio" .../>@ tags for a mailer form.  The 'name' attribute is required. 
     
    117117    end 
    118118 
    119     desc %{ Renders an @<option/>@ tag if the parent is a  
    120     @<r:mailer:select>...</r:mailer:select>@ tag, an @<input type="radio"/>@ tag if  
     119    desc %{ Renders an @<option/>@ tag if the parent is a 
     120    @<r:mailer:select>...</r:mailer:select>@ tag, an @<input type="radio"/>@ tag if 
    121121    the parent is a @<r:mailer:radiogroup>...</r:mailer:radiogroup>@ } 
    122122    tag 'mailer:option' do |tag| 
     
    165165              </script> 
    166166        } 
    167         end       
    168       end 
    169     end 
    170      
     167        end 
     168      end 
     169    end 
     170 
    171171    tag "mailer:email_option:label" do |tag| 
    172172      tag.locals.params['label'] = tag.expand.strip 
    173173    end 
    174    
     174 
    175175    tag "mailer:email_option:address" do |tag| 
    176176      tag.locals.params['address'] = tag.expand.strip 
    177177    end 
    178    
    179      
    180     desc %{ 
    181     Renders the value of a datum submitted via a mailer form.  Used in the 'email', 'email_html', and  
     178 
     179 
     180    desc %{ 
     181    Renders the value of a datum submitted via a mailer form.  Used in the 'email', 'email_html', and 
    182182    'config' parts to generate the resulting email. } 
    183183    tag 'mailer:get' do |tag| 
     
    188188        form_data.to_hash.to_yaml.to_s 
    189189      end 
    190     end   
     190    end 
    191191 
    192192protected 
     
    199199    results << "#{add_attrs_to("", options)}/>" 
    200200  end 
    201    
     201 
    202202  def add_attrs_to(results, tag_attrs=tag_attr) 
    203203    # Well, turns out I stringify the keys so I can sort them so I can test the tag output 
     
    207207    results 
    208208  end 
    209    
     209 
    210210  # Get the default css class based on type 
    211211  def get_class_name(type, class_name=nil) 
     
    216216    class_name 
    217217  end 
    218    
     218 
    219219  # Raises a 'name missing' tag error 
    220220  def raise_name_error(tag_name) 
     
    224224    raise_name_error( tag_name ) if tag_attr[:name].nil? or tag_attr[:name].empty? 
    225225  end 
    226    
     226 
    227227  # Does the work of actually sending the emails 
    228228  def send_mail() 
     
    254254            @headers = options[:headers] || {} 
    255255            @charset = options[:charset] || "utf-8" 
    256             @content_type = "multipart/alternative"             
     256            @content_type = "multipart/alternative" 
    257257              if options.has_key? :plain_body 
    258258                part :content_type => "text/plain", :body => (options[:plain_body] || "") 
     
    260260              if options.has_key? :html_body and !options[:html_body].blank? 
    261261                part :content_type => "text/html", :body => (options[:html_body] || "") 
    262               end             
     262              end 
    263263          end 
    264264      CODE