From 45d473a64628b26d64d56f2dc2a309c0f31b4e35 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sun, 2 Jul 2017 09:16:05 +1000 Subject: [PATCH] move logistics emails also --- booking.emails_admin.inc | 70 +++++++++++++++++++++++++++++++++++++--- booking.module | 10 +++++- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/booking.emails_admin.inc b/booking.emails_admin.inc index 59cf3a5..a364eba 100644 --- a/booking.emails_admin.inc +++ b/booking.emails_admin.inc @@ -74,7 +74,7 @@ function booking_emails_workflow_admin() { '#type' => 'fieldset', '#title' => 'Built-In Workflow Email Definitions', '#collapsible' => TRUE, - '#collapsed' => TRUE, + '#collapsed' => FALSE, ); //if HTML mail is enabled, allow user to specify footer @@ -259,8 +259,9 @@ function booking_emails_workflow_admin() { ); } */ - + /*Text for logistics emails*/ + /* $form['custom-logistics-emails'] = array( '#type' => 'fieldset', '#title' => 'Custom Logistics Email Text Definitions', @@ -288,7 +289,7 @@ function booking_emails_workflow_admin() { '#format' => $form_format, ); } - + */ //let the builtin hook do all the hard work return system_settings_form($form, FALSE); } @@ -319,11 +320,68 @@ function booking_emails_custom_admin() { ); /*Text for emails*/ + $form['custom-logistics-emails'] = array( + '#type' => 'fieldset', + '#title' => 'Custom Logistics Email Text Definitions', + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + + //add a bunch of custom emails + //@todo add an admin variable for this + for ($i = 1; $i <= 5; $i++) { + $subject_fieldname = 'booking_email_subject_customlogistics' . $i; + $body_fieldname = 'booking_email_customlogistics' . $i; + $form['custom-logistics-emails'][$subject_fieldname] = array ( + '#type' => 'textfield', + '#title' => t('Subject line for Logistics Custom Email ' . $i), + '#size' => 150, + '#maxlength' => 300, + '#default_value' => variable_get($subject_fieldname,'[booking:eventname] Logistics'), + ); + $form['custom-logistics-emails'][$body_fieldname] = array( + '#title' => t('Email text for Logistics 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, + ); + } + //let the builtin hook do all the hard work + return system_settings_form($form, FALSE); +} + +/** + * Function to allow admin user to define custom logistics emails that can be sent by Bookings module, from the logistics email address + * + * @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 logistics emails*/ $form['custom-emails'] = array( '#type' => 'fieldset', '#title' => 'Custom Email Text Definitions', '#collapsible' => TRUE, - '#collapsed' => TRUE, + '#collapsed' => FALSE, ); //add a bunch of custom emails @@ -344,7 +402,9 @@ function booking_emails_custom_admin() { '#type' => $form_type, '#format' => $form_format, ); - } + } + //let the builtin hook do all the hard work + return system_settings_form($form, FALSE); } /** diff --git a/booking.module b/booking.module index 5fa390a..5cfe115 100644 --- a/booking.module +++ b/booking.module @@ -205,7 +205,15 @@ function booking_menu() { 'file' => 'booking.emails_admin.inc', 'type' => MENU_LOCAL_ACTION, ); - + $items['admin/config/booking/emails/logistics'] = array( + 'title' => 'Booking module custom logistics email definitions', + 'description' => 'Configure custom logistics emails used by the Booking module', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('booking_emails_customlogistics_admin'), + 'access arguments' => array('access administration pages'), + 'file' => 'booking.emails_admin.inc', + 'type' => MENU_LOCAL_ACTION, + ); $items['admin/config/booking/events'] = array( 'title' => 'Booking module event settings', 'description' => 'Configure events for the Booking module',