From 4768fe7ba1e84c076129f192759e382931c5f78b Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 27 Jun 2017 20:28:46 +1000 Subject: [PATCH] test --- booking.admin.inc | 13 ++++++++++++- booking.emails_admin.inc | 16 +++++++++++++--- booking.install | 10 ++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/booking.admin.inc b/booking.admin.inc index bd10f9a..ddca8df 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -17,7 +17,7 @@ function booking_admin() { 'booking' => 'BookingMailSystem', )); */ - + //create the mysql view booking_person_view if necessary try { $sqlview_check = db_query("SELECT * FROM {booking_person_view}")->fetchAssoc(); @@ -34,6 +34,17 @@ function booking_admin() { '#title' => 'Email Addresses', '#collapsible' => TRUE, ); + + $form['features']['booking_enable_html_mail'] = array( + '#type' => 'radios', + '#title' => t('Enable html emails?'), + '#description' => t('Turn this feature on for html based emails, otherwise plaintext emails will be used. HTML based emails will require a custom template file to be defined.'), + '#options' => array( + 0 => t('No'), + t('Yes') + ), + '#default_value' => variable_get('booking_enable_html_mail', 0) + ); $form['email']['booking_from_email'] = array( '#type' => 'textfield', diff --git a/booking.emails_admin.inc b/booking.emails_admin.inc index 1fc5008..3b1e61b 100644 --- a/booking.emails_admin.inc +++ b/booking.emails_admin.inc @@ -47,6 +47,18 @@ function booking_emails_admin() { "Love in Jesus,\n[booking:eventname] Registrations Team."; $booking_email_notcoming_demotion = ""; $booking_email_paymentoutstanding_married_text = ""; + + if(variable_get('booking_enable_html_mail', 0) == 1) { + $textarea_defaults = array( + '#type' => 'text_format', + '#format' => 'full_html', + ); + } + else { + $textarea_defaults = array( + '#type' => 'textarea', + ); + } //include the token definitions $form['tokens'] = array( @@ -70,12 +82,10 @@ function booking_emails_admin() { ); $form['emails']['booking_email_bookedin_text'] = array( '#title' => t('Registration Successful Email'), - //'#type' => 'textarea', - '#type' => 'text_format', - '#format' => 'full_html', '#description' => t('Text to use in an email indicating the person has booked in, paid their deposit and is not on the waiting list'), '#default_value' => variable_get('booking_email_bookedin_text', $default_email_text), ); + $form['emails']['booking_email_bookedin_text'][] = $textarea_defaults; $form['emails']['booking_email_regn_complete_text'] = array( '#title' => t('Payment Complete Email'), '#type' => 'textarea', diff --git a/booking.install b/booking.install index b5b5c36..93993f6 100644 --- a/booking.install +++ b/booking.install @@ -651,6 +651,15 @@ function booking_update_7242() { _booking_node_create_mysqlview(); } +/** +* Add support for html emails +*/ +function booking_update_7243() { + $current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem')); + $addition = array('booking' => 'BookingMailSystem'); + variable_set('mail_system', array_merge($current, $addition)); +} + /** * Implementation of hook_install(). */ @@ -692,6 +701,7 @@ function booking_uninstall() { /** * Implement hook_enable() + * Based on https://drupal.stackexchange.com/questions/23821/email-a-whole-node-including-template-contents */ function booking_enable() { drupal_set_message($message = t('The Booking System module was successfully enabled.'), $type = 'status');