/[drupal]/contributions/modules/addressbook/addressbook.module
ViewVC logotype

Diff of /contributions/modules/addressbook/addressbook.module

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

revision 1.30 by wplaat, Wed Sep 16 19:03:47 2009 UTC revision 1.31 by wplaat, Thu Sep 17 16:03:20 2009 UTC
# Line 45  function addressbook_help($path, $arg) { Line 45  function addressbook_help($path, $arg) {
45    return $output;    return $output;
46  }  }
47    
48    function addressbook_mail($key, &$message, $params)
49    {
50      $message['subject'] = $params['subject'];
51      $message['body'] = $params['body'];
52    }
53    
54  /**  /**
55   * menu hook()   * menu hook()
56   * @return array of menu items   * @return array of menu items
# Line 313  function addressbook_cron() { Line 319  function addressbook_cron() {
319            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';            $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';
320    
321            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');            $subject=variable_get('addressbook_birthday_subject','Happy birthday %username from %site_name');
322            $subject = str_replace("%username", $username, $subject);            $subject=str_replace("%username", $username, $subject);
323            $subject = str_replace("%site_name", $site_name, $subject);            $subject=str_replace("%site_name", $site_name, $subject);
324    
325            $message=variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n");            $body=variable_get('addressbook_birthday_body',"Dear %username,\r\n\r\nCongratulation with your %user_age ste birthday.\r\nHave a nice day!\r\n");
326            $message = str_replace("%username", $username, $message);            $body=str_replace("%username", $username, $body);
327            $message = str_replace("%user_age", $user_age, $message);            $body=str_replace("%user_age", $user_age, $body);
328            $message = str_replace("%site_name", $site_name, $message);            $body=str_replace("%site_name", $site_name, $body);
329    
330            //if ( drupal_mail('addressbook', 'notice', $account->mail, user_preferred_language($account), $params);            if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))
           if ( drupal_mail( "addressbook", $email, $subject, $message, $from))  
331            {            {
332              watchdog('cron', t('Sent birthday email to ').$email);              watchdog('cron', t('Sent birthday email to ').$email);
333            }            }
# Line 2062  function email_view( $sort='') Line 2067  function email_view( $sort='')
2067    
2068    if ($commit=='0')    if ($commit=='0')
2069    {    {
2070         $page .= '<table align="left" width="100%">';
2071       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';       $page .= '<form action="'.url(URL_EMAIL.'/'.$sort).'" method="POST">';
2072       $page .= '<br/>';       $page .= '<br/>';
2073       $page .= t('To:');       $page .= t('To:');
2074       $page .= '<br/>';       $page .= '<br/>';
2075       $page .= '<textarea id="email" cols=140 rows=5 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';       $page .= '<textarea id="email" rows=5 cols=100 maxlength="2000" name="email" WRAP=HARD READONLY>'.$email.'</textarea>';
2076       $page .= '<br/>';       $page .= '<br/>';
2077       $page .= '<br/>';       $page .= '<br/>';
2078       $page .= t('Subject:');       $page .= t('Subject:');
2079       $page .= '<br/>';       $page .= '<br/>';
2080       $page .= '<input id="text" name="subject" size="143" maxlength="143" type="text" value="'.$subject.'" />';       $page .= '<input id="text" name="subject" size=100 maxlength="143" type="text" value="'.$subject.'" />';
2081       $page .= '<br/>';       $page .= '<br/>';
2082       $page .= '<br/>';       $page .= '<br/>';
2083       $page .= t('Content:');       $page .= t('Content:');
2084       $page .= '<br/>';       $page .= '<br/>';
2085       $page .= '<textarea id="body" cols=140 rows=10 maxlength="2000" name="body" >'.$body.'</textarea>';       $page .= '<textarea id="body" rows=10 cols=100 maxlength="2000" name="body" >'.$body.'</textarea>';
2086       $page .= '<br/>';       $page .= '<br/>';
2087       $page .= '<br/>';       $page .= '<br/>';
2088       $page .= '<table align="left">';       $page .= '<table align="left">';
# Line 2089  function email_view( $sort='') Line 2095  function email_view( $sort='')
2095       $page .= '</td></tr>';       $page .= '</td></tr>';
2096       $page .= '</form>';       $page .= '</form>';
2097       $page .= '</table>';       $page .= '</table>';
2098         $page .= '</table>';
2099    }    }
2100    else    else
2101    {    {
      $from=$site_name.'<'.variable_get('site_mail', ini_get('sendmail_from')).'>';  
   
2102       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';       $page .= '<form action="'.url(URL_MEMBER_LIST.'/'.$_SESSION["sort"]).'" method="POST">';
2103       $page .= '<br/>';       $page .= '<br/>';
2104    
2105       if ( drupal_mail( "addressbook", $email, $subject, $body, $from))       if (drupal_mail('Addressbook', 'send', $email, user_preferred_language($user), array('subject'=>$subject,'body'=>$body)))
2106       {       {
2107          watchdog('Addressbook', t('Sent group email to ').$email);          watchdog('Addressbook', t('Sent group email to ').$email);
2108          $page .= t('Email is sent!');          $page .= t('Email is sent to '.$email);
2109       }       }
2110       else       else
2111       {       {
2112          watchdog('Addressbook', t('Unable to email to ').$email);          watchdog('Addressbook', t('Unable to email to ').$email);
2113          $page .= t('Unable to email!');          $page .= t('Unable to email to '.$email);
2114       }       }
   
2115       $page .= '<br/>';       $page .= '<br/>';
2116       $page .= '<br/>';       $page .= '<br/>';
2117       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';       $page .= '<input type="submit" name="return" value="'.t('Return').'" />';

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.3