diff -urp print/print.module print_updated/print.module --- print/print.module 2009-10-22 12:26:31.728125000 -0400 +++ print_updated/print.module 2009-10-22 12:34:24.125000000 -0400 @@ -398,37 +398,6 @@ function print_form_alter(&$form, $form_ $form['print']['print_display_comment']['#default_value'] = variable_get('print_display_comment_'. $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); $form['print']['print_display_urllist']['#default_value'] = variable_get('print_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT); $form['print']['label']['#value'] = '

'. t('The settings below only apply when some of the corresponding module-wide link settings are enabled.') .'

'. $form['print']['label']['#value']; - - // Node Type Specific Mail Text Settings - $form['print']['mail'] = array ( - '#type' => 'fieldset', - '#title' => t('E-mail text settings'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['print']['mail']['to'] = array ( - '#type' => 'textfield', - '#title' => t('Recipients'), - '#default_value' => variable_get('print_mail_to_'. $form['#node_type']->type, ''), - '#size' => 60, - '#maxlength' => 250, - '#description' => t('A comma-separated list of recipient e-mail addresses and / or tokens.'), - ); - $form['print']['mail']['subject'] = array ( - '#type' => 'textfield', - '#title' => t('Subject'), - '#default_value' => variable_get('print_mail_subject_'. $form['#node_type']->type, ''), - '#size' => 60, - '#maxlength' => 250, - '#description' => t('A string of text and / or tokens to be used as the default e-mail subject.'), - ); - $form['print']['mail']['message'] = array ( - '#type' => 'textarea', - '#title' => t('Message'), - '#default_value' => variable_get('print_mail_message_'. $form['#node_type']->type, ''), - '#rows' => 3, - '#description' => t('A string of text and / or tokens to be used as the default e-mail message.'), - ); } else { $node = $form['#node']; diff -urp print/print_mail/print_mail.inc print_updated/print_mail/print_mail.inc --- print/print_mail/print_mail.inc 2009-10-03 12:52:10.000000000 -0400 +++ print_updated/print_mail/print_mail.inc 2009-10-23 14:03:44.015625000 -0400 @@ -12,6 +12,7 @@ */ require_once(drupal_get_path('module', 'print') .'/print.pages.inc'); +require_once 'Mail/mime.php'; /** * Menu callback for the send by e-mail form. @@ -43,10 +44,13 @@ function print_mail_form($form_state) { $path = 'node/'. $path; } $cid = isset($_GET['comment']) ? (int)$_GET['comment'] : NULL; - $title = _print_get_title($path); + // Load the node to access node type variables + $nodepath = drupal_get_normal_path($path); + $node = node_load(substr($nodepath, 5)); + + // Incremement or initialize print counter if (count($form_state['post']) == 0) { - $nodepath = drupal_get_normal_path($path); db_query("UPDATE {print_mail_page_counter} SET totalcount = totalcount + 1, timestamp = %d WHERE path = '%s'", time(), $nodepath); // If we affected 0 rows, this is the first time viewing the node. if (!db_affected_rows()) { @@ -55,22 +59,34 @@ function print_mail_form($form_state) { } } + // Define replacement tokens for default text + $print_tokens = array( + '!user' => $user->uid != 0 ? check_plain(strip_tags(theme('username', $user))) : t('Someone'), + '!site' => variable_get('site_name', t('an interesting site')), + '!title' => _print_get_title($path), + ); + $form['path'] = array('#type' => 'value', '#value' => $path); $form['cid'] = array('#type' => 'value', '#value' => $cid); + $form['nid'] = array('#type' => 'value', '#value' => $node->nid); $form['fld_from_addr'] = array( '#type' => 'textfield', '#title' => t('Your e-mail'), + '#default_value' => $user->uid != 0 ? $user->mail : '', + '#disabled' => $user->uid != 0 ? TRUE : FALSE, '#size' => 62, ); $form['fld_from_name'] = array( '#type' => 'textfield', '#title' => t('Your name'), + '#default_value' => $user->uid != 0 ? $print_tokens['!user'] : '', '#size' => 62, ); $form['txt_to_addrs'] = array( '#type' => 'textarea', '#title' => t('Send to'), + '#default_value' => variable_get('print_mail_text_to_'. $node->type, ''), '#rows' => 3, '#resizable' => FALSE, '#description' => t('Enter multiple addresses separated by commas and/or different lines.'), @@ -78,16 +94,30 @@ function print_mail_form($form_state) { $form['fld_subject'] = array( '#type' => 'textfield', '#title' => t('Subject'), + '#default_value' => variable_get('print_mail_text_subject_'. $node->type, + variable_get('print_mail_text_subject', t('!user has sent you a message from !site', $print_tokens)) + ), '#size' => 62, ); $form['fld_title'] = array( '#type' => 'item', '#title' => t('Page to be sent'), - '#value' => l($title, $path, array('attributes' => array('title' => t('View page')))), + '#value' => l($print_tokens['!title'], $path, array('attributes' => array('title' => t('View page')))), + ); + $form['fld_send_option'] = array ( + '#type' => 'select', + '#title' => t('Send page as'), + '#default_value' => 'plain-attachment', + '#options' => array( + 'sendpage' => 'Inline HTML', + 'inline-attachment' => 'Inline HTML with Attachment', + 'plain-attachment' => 'Plain Text with Attachment', + ), ); $form['txt_message'] = array( '#type' => 'textarea', '#title' => t('Your message'), + '#default_value' => variable_get('print_mail_text_message_'. $node->type, variable_get('print_mail_text_content', '')), '#rows' => 6, ); @@ -117,21 +147,12 @@ function print_mail_form($form_state) { '#value' => t('Cancel'), ); - if ($user->uid != 0) { - $user_name = check_plain(strip_tags(theme('username', $user))); - $form['fld_from_addr']['#default_value'] = $user->mail; - $form['fld_from_addr']['#disabled'] = TRUE; - $form['fld_from_addr']['#value'] = $user->mail; - $form['fld_from_name']['#default_value'] = $user_name; - } - else { - $user_name = t('Someone'); + // Token support + if (module_exists('token')) { + $form['txt_to_addrs']['#default_value'] = token_replace($form['txt_to_addrs']['#default_value'], 'node', $node); + $form['fld_subject']['#default_value'] = token_replace($form['fld_subject']['#default_value'], 'node', $node); + $form['txt_message']['#default_value'] = token_replace($form['txt_message']['#default_value'], 'node', $node); } - $site_name = variable_get('site_name', t('an interesting site')); - $print_mail_text_subject = filter_xss(variable_get('print_mail_text_subject', t('!user has sent you a message from !site'))); - $form['fld_subject']['#default_value'] = t($print_mail_text_subject, array('!user' => $user_name, '!site' => $site_name, '!title' => $title)); - $print_mail_text_content = filter_xss(variable_get('print_mail_text_content', '')); - $form['txt_message']['#default_value'] = t($print_mail_text_content); return $form; } @@ -155,6 +176,7 @@ function theme_print_mail_form($form) { case 'txt_to_addrs': case 'fld_subject': case 'fld_title': + case 'fld_send_option': $tmp = str_replace('setTXTBody($params['message']); + if ($params['send_option'] == 'inline-attachment') { + $mime->setHTMLBody($params['body']); + } + $mime->addAttachment($params['body'],'text/html','test-file.html',false); + + // Store MIME message output in message array + $message['body'] = $mime->get($mime_params); + $message['headers'] = $mime->headers($message['headers']); + + // Strip special characters from Content-Type header + // Required to prevent mime_header_encode() from disrupting Content-Type header + $message['headers']['Content-Type'] = preg_replace('/[^\x20-\x7E]/','', $message['headers']['Content-Type']); + break; } } diff -urp print/print_mail/print_mail.module print_updated/print_mail/print_mail.module --- print/print_mail/print_mail.module 2009-10-15 19:43:28.000000000 -0400 +++ print_updated/print_mail/print_mail.module 2009-10-22 15:16:15.531250000 -0400 @@ -256,7 +256,37 @@ function print_mail_form_alter(&$form, $ $form['print']['print_mail_display']['#default_value'] = variable_get('print_mail_display_'. $form['#node_type']->type, PRINT_TYPE_SHOW_LINK_DEFAULT); $form['print']['print_mail_display_comment']['#default_value'] = variable_get('print_mail_display_comment_'. $form['#node_type']->type, PRINT_TYPE_COMMENT_LINK_DEFAULT); $form['print']['print_mail_display_urllist']['#default_value'] = variable_get('print_mail_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT); - } + + // Node Type Specific Mail Text Settings + $form['print']['mail'] = array ( + '#type' => 'fieldset', + '#title' => t('E-mail text settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['print']['mail']['print_mail_text_to'] = array ( + '#type' => 'textfield', + '#title' => t('Recipients'), + '#default_value' => variable_get('print_mail_text_to_'. $form['#node_type']->type, ''), + '#size' => 60, + '#maxlength' => 250, + '#description' => t('A comma-separated list of recipient e-mail addresses and / or tokens.'), + ); + $form['print']['mail']['print_mail_text_subject'] = array ( + '#type' => 'textfield', + '#title' => t('Subject'), + '#default_value' => variable_get('print_mail_text_subject_'. $form['#node_type']->type, ''), + '#size' => 60, + '#maxlength' => 250, + '#description' => t('A string of text and / or tokens to be used as the default e-mail subject.'), + ); + $form['print']['mail']['print_mail_text_message'] = array ( + '#type' => 'textarea', + '#title' => t('Message'), + '#default_value' => variable_get('print_mail_text_message_'. $form['#node_type']->type, ''), + '#rows' => 3, + '#description' => t('A string of text and / or tokens to be used as the default e-mail message.'), + ); } else { $node = $form['#node']; $form['print']['print_mail_display']['#default_value'] = isset($node->print_mail_display) ? $node->print_mail_display : PRINT_TYPE_SHOW_LINK_DEFAULT;