move custom emails to their own page

This commit is contained in:
2017-07-02 09:12:35 +10:00
parent 899fd83499
commit 8444477ab2
2 changed files with 66 additions and 3 deletions

View File

@@ -1,6 +1,12 @@
<?php <?php
function booking_emails_admin() { /**
* Function to allow admin user to define contents of workflow emails that can be sent by Bookings module
*
* @param
* @return form render array
*/
function booking_emails_workflow_admin() {
global $event; global $event;
$form = array(); $form = array();
//some initial workflow email definitions //some initial workflow email definitions
@@ -225,6 +231,7 @@ function booking_emails_admin() {
); );
/*Text for emails*/ /*Text for emails*/
/*
$form['custom-emails'] = array( $form['custom-emails'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => 'Custom Email Text Definitions', '#title' => 'Custom Email Text Definitions',
@@ -251,6 +258,7 @@ function booking_emails_admin() {
'#format' => $form_format, '#format' => $form_format,
); );
} }
*/
/*Text for logistics emails*/ /*Text for logistics emails*/
$form['custom-logistics-emails'] = array( $form['custom-logistics-emails'] = array(
@@ -285,6 +293,60 @@ function booking_emails_admin() {
return system_settings_form($form, FALSE); 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 * Function to allow admin user to manually generate and send a workflow or custom email
* *

View File

@@ -190,7 +190,7 @@ function booking_menu() {
'title' => 'Booking module workflow email definitions', 'title' => 'Booking module workflow email definitions',
'description' => 'Configure built-in workflow emails used by the Booking module', 'description' => 'Configure built-in workflow emails used by the Booking module',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('booking_emails_admin'), 'page arguments' => array('booking_emails_workflow_admin'),
'access arguments' => array('access administration pages'), 'access arguments' => array('access administration pages'),
'file' => 'booking.emails_admin.inc', 'file' => 'booking.emails_admin.inc',
'weight' => -98, 'weight' => -98,
@@ -199,7 +199,8 @@ function booking_menu() {
$items['admin/config/booking/emails/custom'] = array( $items['admin/config/booking/emails/custom'] = array(
'title' => 'Booking module custom email definitions', 'title' => 'Booking module custom email definitions',
'description' => 'Configure custom emails used by the Booking module', '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'), 'access arguments' => array('access administration pages'),
'file' => 'booking.emails_admin.inc', 'file' => 'booking.emails_admin.inc',
'type' => MENU_LOCAL_ACTION, 'type' => MENU_LOCAL_ACTION,