? ed_classified-503792-1.patch ? patches Index: ed_classified.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ed_classified/ed_classified.module,v retrieving revision 1.1.4.45.2.11 diff -u -p -r1.1.4.45.2.11 ed_classified.module --- ed_classified.module 27 Jun 2009 04:46:28 -0000 1.1.4.45.2.11 +++ ed_classified.module 27 Jun 2009 12:46:36 -0000 @@ -48,7 +48,7 @@ define('EDI_CLASSIFIED_VAR_DEF_ALTER_ATT define('EDI_CLASSIFIED_VAR_DEF_EMAIL_BODY', 'One or more of your classified ads on !sitename (!siteurl) are expiring soon. Please sign in and visit !user_ads_url to check your ads.'); define('EDI_CLASSIFIED_VAR_DEF_EMAIL_SUBJ', '!sitename reminder: classified ads expiring soon!'); define('EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_BODY', 'A classified ad on !sitename (!siteurl) has expired. Please sign in and visit !user_ads_url to check your ads.'); -define('EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ', '!sitename notifiation: classified ad expired!'); +define('EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ', '!sitename notification: classified ad expired!'); define('EDI_CLASSIFIED_BANNER_URL', 'http://exodusdev.com/sites/default/files/ed-classified-banner-small.png'); define('EDI_CLASSIFIED_INFO_URL', 'http://exodusdev.com/drupal/modules/ed_classified.module'); @@ -720,3 +720,25 @@ function ed_classified_node_type($op, $i } } } + +/** + * Implementation of hook_mail() + */ + +function ed_classified_mail($key, &$message, $params) { + $language = $message['language']; + $variables = user_mail_tokens($params['account'], $language); + switch($key) { + case 'expired': + $message['subject'] = t(EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ, $variables, $language->language); + $message['body'][] = t(EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_BODY, $variables, $language->language); + break; + case 'expiring': + $message['subject'] = t(EDI_CLASSIFIED_VAR_DEF_EMAIL_SUBJ, $variables, $language->language); + $message['body'][] = t(EDI_CLASSIFIED_VAR_DEF_EMAIL_BODY, $variables, $language->language); + break; + default: + $message['subject'] = t('Classified Ad notification from !site', $variables, $language->language); + break; + } +} Index: ed_classified_notifications.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ed_classified/Attic/ed_classified_notifications.inc,v retrieving revision 1.1.4.3.4.2 diff -u -p -r1.1.4.3.4.2 ed_classified_notifications.inc --- ed_classified_notifications.inc 26 Jun 2009 02:16:53 -0000 1.1.4.3.4.2 +++ ed_classified_notifications.inc 27 Jun 2009 12:46:36 -0000 @@ -57,7 +57,7 @@ function _ed_classified_notify_advertise $user = user_load(array('uid' => $uid)); // todo: need to send mails only to those with user_access('reset classified ad expiration') && user_access('edit own classified ads') permissions if ($user) { - if (!_ed_classified_send_user_reminder_email($user)) { + if (!_ed_classified_send_user_notification_email($user,'expiring')) { _edi_wd(t('Unable to send ad expiration reminder email to user #!uid', array('!uid' => $uid)), WATCHDOG_ERROR); } } @@ -81,38 +81,19 @@ function _ed_classified_notify_advertise function _ed_classified_notify_user_of_ad_expiration($node) { $ad_author = user_load(array('uid'=>$node->uid)); - _ed_classified_send_user_notification_email($ad_author); + _ed_classified_send_user_notification_email($ad_author,'expired'); } /** * Send an email notification to the specified user */ -function _ed_classified_send_user_notification_email(&$user) { +function _ed_classified_send_user_notification_email(&$user, $key='') { $parms = array('!sitename' => variable_get('site_name', ''), '!user_ads_url' => url('user/'.$user->uid . '/'. EDI_CLASSIFIED_MODULE_NAME, array('absolute' => TRUE)), '!siteurl' => url('', array('absolute' => TRUE))); - $subject = t(_ed_classified_variable_get('email_subj', EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_SUBJ), $parms); - $body = t(_ed_classified_variable_get('email_body', EDI_CLASSIFIED_VAR_DEF_EXP_EMAIL_BODY), $parms); $from = variable_get("site_mail", ini_get("sendmail_from")); // http://drupal.org/node/77689 - return drupal_mail(EDI_CLASSIFIED_MODULE_NAME . '-expiration-notify', $user->mail, $subject, $body, - $from, "Reply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); -} - -/** - * Send an email notification to the specified user - */ - -function _ed_classified_send_user_reminder_email(&$user) { - $parms = array('!sitename' => variable_get('site_name', ''), - '!user_ads_url' => url('user/'.$user->uid . '/'. EDI_CLASSIFIED_MODULE_NAME, array('absolute' => TRUE)), - '!siteurl' => url('', array('absolute' => TRUE))); - $subject = t(_ed_classified_variable_get('email_subj', EDI_CLASSIFIED_VAR_DEF_EMAIL_SUBJ), $parms); - $body = t(_ed_classified_variable_get('email_body', EDI_CLASSIFIED_VAR_DEF_EMAIL_BODY), $parms); - $from = variable_get("site_mail", ini_get("sendmail_from")); // http://drupal.org/node/77689 - - return drupal_mail(EDI_CLASSIFIED_MODULE_NAME . '-expiration-notify', $user->mail, $subject, $body, - $from, "Reply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + return drupal_mail(EDI_CLASSIFIED_MODULE_NAME, $key, $user->mail, user_preferred_language($account), $parms, $from); } /**