/[drupal]/contributions/modules/regcode/regcode_mailer/regcode_mailer.module
ViewVC logotype

Diff of /contributions/modules/regcode/regcode_mailer/regcode_mailer.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.4, Sat Oct 10 20:39:30 2009 UTC revision 1.1.2.5, Wed Oct 21 21:53:34 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: regcode_mailer.module,v 1.1.2.3 2009/10/05 21:58:47 aidan Exp $  // $Id: regcode_mailer.module,v 1.1.2.4 2009/10/10 20:39:30 aidan Exp $
3    
4    
5  /**  /**
# Line 65  function regcode_mailer_admin_list_form( Line 65  function regcode_mailer_admin_list_form(
65    $form['message'] = array (    $form['message'] = array (
66      '#type'        => 'textarea',      '#type'        => 'textarea',
67      '#title'       => t('Body'),      '#title'       => t('Body'),
68      '#description' => t('Enter the plaintext email to be sent to the user. <em>%code%</em> will be substituted for the actual registration code.'),      '#description' => t('Enter the plaintext email to be sent to the user. <em>@code</em> will be substituted for the actual registration code.'),
69      '#rows'        => 15,      '#rows'        => 15,
70    );    );
71    
# Line 106  function regcode_mailer_list_action_mail Line 106  function regcode_mailer_list_action_mail
106        break;        break;
107      }      }
108    
109        // Tokes
110        $tokens = array();
111        foreach ($code as $key => $token) {
112            $tokens['@' . $key] = $token;
113        }
114    
115      // Format the email      // Format the email
116      $params = array (      $params = array (
117        'tokens' => $code,        'tokens'  => $tokens,
118        'message' => $form_state['values']['message'],        'message' => $form_state['values']['message'],
119        'subject' => $form_state['values']['subject'],        'subject' => $form_state['values']['subject'],
120      );      );
121    
122      // Send      // Send
123      $message = drupal_mail('regcode', 'regcode_mail', $email, language_default(), $params);      $message = drupal_mail('regcode_mailer', 'regcode', $email, language_default(), $params);
124      drupal_set_message(t("Sent message with code %code to %email",      drupal_set_message(t("Sent message with code %code to %email",
125        array('%code' => $code['code'], '%email' => $email)));        array('%code' => $code['code'], '%email' => $email)));
126    }    }
# Line 133  function regcode_mailer_regcode_filters( Line 139  function regcode_mailer_regcode_filters(
139    
140    // Create an export list button    // Create an export list button
141    $form['filter']['action_mail'] = array(    $form['filter']['action_mail'] = array(
142      '#type'          => 'submit',      '#type'   => 'submit',
143      '#value'         => t('Mail codes'),      '#value'  => t('Mail codes'),
144      '#submit'        => array('regcode_admin_list_savefilters',      '#submit' => array(
145                            'regcode_mailer_regcode_action_gotomail'),        'regcode_admin_list_savefilters',
146          'regcode_mailer_regcode_action_gotomail'
147          ),
148    );    );
149    
150    return $form;    return $form;
   
151  }  }
152    
153    
# Line 157  function regcode_mailer_regcode_action_g Line 164  function regcode_mailer_regcode_action_g
164   */   */
165  function regcode_mailer_mail($key, &$message, $params) {  function regcode_mailer_mail($key, &$message, $params) {
166    switch($key) {    switch($key) {
167      case 'regcode_mail':      case 'regcode':
168        $message['subject'] = $params['subject'];        $message['subject'] = t($params['subject'], $params['tokens']);
169        $body = $params['message'];        $message['body'][]  = t($params['message'], $params['tokens']);
       foreach ($params['tokens'] as $key => $value) {  
         $body = str_replace("%{$key}%", $value, $body) ;  
       }  
       $message['body'][] = $body;  
170        break;        break;
171    }    }
   
   return $message;  
172  }  }

Legend:
Removed from v.1.1.2.4  
changed lines
  Added in v.1.1.2.5

  ViewVC Help
Powered by ViewVC 1.1.2