diff -urp Download/mail_logger/mail_logger.module /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/mail_logger/mail_logger.module --- Download/mail_logger/mail_logger.module 2008-05-26 01:30:30.000000000 +0200 +++ /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/mail_logger/mail_logger.module 2009-08-27 10:07:19.000000000 +0200 @@ -5,7 +5,7 @@ * */ function mail_logger_boot() { - //because modules can modify the outgoing mail, mail_logger must be executed last in order to capture + //because modules can modify the outgoing mail, mail_logger must be executed last in order to capture //the final mail parameters by setting the weight of mail_logger to something ridicolous $max_weight = db_result(db_query("select max(weight) from {system} where name != 'mail_logger'")); db_query("UPDATE {system} SET weight = %d WHERE name = 'mail_logger'", $max_weight + 100); @@ -38,6 +38,14 @@ function mail_logger_menu() { 'access arguments' => array('access mail logger'), 'type' => MENU_CALLBACK, ); + $items['admin/reports/mail-logger/resend/%'] = array( + 'title' => t('Outgoing Mail log entries'), + 'description' => t('Resend a logged mail'), + 'page callback' => 'mail_logger_resend_mail', + 'page arguments' => array(4), + 'access arguments' => array('access mail logger'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -50,7 +58,7 @@ function mail_logger_theme() { } function mail_logger_read_mail($id) { if(!isset($id) || !is_numeric($id)) { - return 'Invalid Mail Logger ID parameter'; + return 'Invalid Mail Logger ID parameter'; } else if ($result = db_query('SELECT * FROM {mail_logger} WHERE mlid = %d LIMIT 1', $id) ) { drupal_add_css(drupal_get_path('module', 'mail_logger') .'/mail_logger.css'); @@ -60,6 +68,21 @@ function mail_logger_read_mail($id) { return 'No Mail Logger record found with id '. $id; } } +function mail_logger_resend_mail($id) { + if(!isset($id) || !is_numeric($id)) { + return 'Invalid Mail Logger ID parameter'; + } + else if ($result = db_query('SELECT * FROM {mail_logger} WHERE mlid = %d LIMIT 1', $id) ) { + $mail = db_fetch_object($result); + // Resend mail with own module and key. + // Using original module and key would cause that the mail would be rebuild/altered again. + drupal_mail('mail_logger', 'resend', $mail->to, $mail->language, '', $mail->from); + drupal_goto('admin/reports/mail-logger'); + } + else { + return 'No Mail Logger record found with id '. $id; + } +} function theme_mail_logger_read_mail($mail) { $output = ''; @@ -84,22 +107,26 @@ function mail_logger_mail_alter(&$messag //drupal_set_message('
'. print_r($message, 1) .''); //return ; //this line taken from mail.inc:drupal_mail() - $message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']); - $args = array( - $message['id'], - $message['to'], - $message['subject'], - $message['body'], - $message['from'], - serialize($message['headers']), - time(), - $message['language']->language, - ); - - db_query("INSERT INTO {mail_logger} ( - `mlid` , `mailkey` , `to` , `subject` , `body` , `from` , `headers`, `date_sent`, `language` - ) VALUES ( - NULL, '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s' )", $args); + + if ($message['id'] != 'mail_logger_resend') { + // Don't log message that are a resend of the original one + $message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']); + $args = array( + $message['id'], + $message['to'], + $message['subject'], + $message['body'], + $message['from'], + serialize($message['headers']), + time(), + $message['language']->language, + ); + + db_query("INSERT INTO {mail_logger} ( + `mlid` , `mailkey` , `to` , `subject` , `body` , `from` , `headers`, `date_sent`, `language` + ) VALUES ( + NULL, '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s' )", $args); + } } /** @@ -164,12 +191,13 @@ function mail_logger_overview() { array('data' => t('From'), 'field' => 'ml.from'), array('data' => t('Subject'), 'field' => 'ml.subject'), array('data' => t('Date Sent'), 'field' => 'ml.date_sent'), + t('Actions') ); $tablesort = tablesort_sql($header); $sql = "SELECT ml.mlid, ml.mailkey, ml.to, ml.from, ml.subject, ml.date_sent FROM {mail_logger} ml"; $type = $_SESSION['mail_logger_overview_filter']; - + if ($type != 'all') { $result = pager_query($sql ." WHERE ml.mailkey = '%s'". $tablesort, 50, 0, NULL, $type); } @@ -186,6 +214,7 @@ function mail_logger_overview() { $mail_logger->from, l(truncate_utf8($mail_logger->subject, 56, TRUE, TRUE), 'admin/reports/mail-logger/mail/'. $mail_logger->mlid ), format_date($mail_logger->date_sent, 'small'), + l(t('Resend'), 'admin/reports/mail-logger/resend/'. $mail_logger->mlid ), ), ); } Only in /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/mail_logger/: mail_logger_resend.patch Only in /var/vhosts/web_drupal_6/http/sites/all/modules/contributed/mail_logger/: .svn