From 8444477ab28b4a588658bdefd31f2e55969b31c6 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 2 Jul 2017 09:12:35 +1000 Subject: [PATCH] move custom emails to their own page --- booking.emails_admin.inc | 64 +++++++++++++++++++++++++++++++++++++++- booking.module | 5 ++-- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/booking.emails_admin.inc b/booking.emails_admin.inc index 41aca4c..59cf3a5 100644 --- a/booking.emails_admin.inc +++ b/booking.emails_admin.inc @@ -1,6 +1,12 @@ 'fieldset', '#title' => 'Custom Email Text Definitions', @@ -251,6 +258,7 @@ function booking_emails_admin() { '#format' => $form_format, ); } + */ /*Text for logistics emails*/ $form['custom-logistics-emails'] = array( @@ -285,6 +293,60 @@ function booking_emails_admin() { return system_settings_form($form, FALSE); } +/** + * Function to allow admin user to define custom emails that can be sent by Bookings module + * + * @param + * @return form render array + */ +function booking_emails_custom_admin() { + global $event; + $form = array(); + + if(variable_get('booking_enable_html_mail', 0) == 1) { + $form_type = 'text_format'; + $form_format = 'full_html'; + } + else { + $form_type = 'textarea'; + $form_format = NULL; + } + + //include the token definitions + $form['tokens'] = array( + '#theme' => 'token_tree', + '#token_types' => array('booking'), + ); + + /*Text for emails*/ + $form['custom-emails'] = array( + '#type' => 'fieldset', + '#title' => 'Custom Email Text Definitions', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + + //add a bunch of custom emails + for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) { + $subject_fieldname = 'booking_email_subject_custom' . $i; + $body_fieldname = 'booking_email_custom' . $i; + $form['custom-emails'][$subject_fieldname] = array ( + '#type' => 'textfield', + '#title' => t('Subject line for Custom Email ' . $i), + '#size' => 150, + '#maxlength' => 300, + '#default_value' => variable_get($subject_fieldname,'[booking:eventname]'), + ); + $form['custom-emails'][$body_fieldname] = array( + '#title' => t('Email text for custom email ' . $i), + '#description' => t(''), + '#default_value' => isset(variable_get($body_fieldname)['value']) ? variable_get($body_fieldname)['value'] : variable_get($body_fieldname, ''), + '#type' => $form_type, + '#format' => $form_format, + ); + } +} + /** * Function to allow admin user to manually generate and send a workflow or custom email * diff --git a/booking.module b/booking.module index 921f958..5fa390a 100644 --- a/booking.module +++ b/booking.module @@ -190,7 +190,7 @@ function booking_menu() { 'title' => 'Booking module workflow email definitions', 'description' => 'Configure built-in workflow emails used by the Booking module', 'page callback' => 'drupal_get_form', - 'page arguments' => array('booking_emails_admin'), + 'page arguments' => array('booking_emails_workflow_admin'), 'access arguments' => array('access administration pages'), 'file' => 'booking.emails_admin.inc', 'weight' => -98, @@ -199,7 +199,8 @@ function booking_menu() { $items['admin/config/booking/emails/custom'] = array( 'title' => 'Booking module custom email definitions', 'description' => 'Configure custom emails used by the Booking module', - 'page callback' => 'booking_emails_admin', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_emails_custom_admin'), 'access arguments' => array('access administration pages'), 'file' => 'booking.emails_admin.inc', 'type' => MENU_LOCAL_ACTION,