Add option to set default mail sending format
authorJoao Ventura
Sat, 24 Jul 2010 16:01:10 +0000 (16:01 +0000)
committerJoao Ventura
Sat, 24 Jul 2010 16:01:10 +0000 (16:01 +0000)
print_mail/print_mail.admin.inc
print_mail/print_mail.inc
print_mail/print_mail.module

index 4bc6f42..a49e6b7 100644 (file)
@@ -11,6 +11,9 @@
  * @ingroup print
  */
 
+// Include MIME library
+@include_once('Mail/mime.php');
+
 /**
  * Menu callback for the send by e-mail module settings form.
  *
@@ -146,6 +149,20 @@ function print_mail_settings() {
     '#description' => t('If checked, the user will be able to choose between sending the full content or only the teaser at send time.'),
   );
 
+  $form['settings']['print_mail_send_option_default'] = array(
+    '#type' => 'select',
+    '#title' => t('Default e-mail sending format'),
+    '#default_value' => variable_get('print_mail_send_option_default', PRINT_MAIL_SEND_OPTION_DEFAULT),
+    '#options' => array(
+      'sendlink' => 'Link',
+      'sendpage' => 'Inline HTML',
+    ),
+  );
+  if (class_exists('Mail_mime')) {
+    $form['settings']['print_mail_send_option_default']['#options']['inline-attachment'] = 'Inline HTML with Attachment';
+    $form['settings']['print_mail_send_option_default']['#options']['plain-attachment'] = 'Plain Text with Attachment';
+  }
+
   if (module_exists('job_queue')) {
     $form['settings']['print_mail_job_queue'] = array(
       '#type' => 'checkbox',
index 0fd8ddb..b9f95f1 100644 (file)
@@ -97,14 +97,13 @@ function print_mail_form($form_state) {
   $form['fld_send_option'] = array(
     '#type' => 'select',
     '#title' => t('Send page as'),
-    '#default_value' => 'sendpage',
+    '#default_value' => variable_get('print_mail_send_option_default', PRINT_MAIL_SEND_OPTION_DEFAULT),
     '#options' => array(
       'sendlink' => 'Link',
       'sendpage' => 'Inline HTML',
     ),
   );
   if (class_exists('Mail_mime')) {
-    $form['fld_send_option']['#default_value'] = 'plain-attachment';
     $form['fld_send_option']['#options']['inline-attachment'] = 'Inline HTML with Attachment';
     $form['fld_send_option']['#options']['plain-attachment'] = 'Plain Text with Attachment';
   }
index f788dbb..ecdfcc2 100644 (file)
@@ -25,6 +25,7 @@ define('PRINT_MAIL_BOOK_LINK_DEFAULT', 1);
 define('PRINT_MAIL_HOURLY_THRESHOLD', 3);
 define('PRINT_MAIL_TEASER_DEFAULT_DEFAULT', 1);
 define('PRINT_MAIL_TEASER_CHOICE_DEFAULT', 1);
+define('PRINT_MAIL_SEND_OPTION_DEFAULT', 'sendpage');
 define('PRINT_MAIL_JOB_QUEUE_DEFAULT', 0);
 
 /**