start adding html email template customisability

This commit is contained in:
2017-09-15 12:54:33 +10:00
parent e1cb00858f
commit 76ac3fbead
4 changed files with 175 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.DS_Store
images/Thumbs.db

View File

@@ -736,6 +736,39 @@ function booking_update_7249() {
_booking_node_create_mysqlview();
}
/**
* Create table to store configuration for HTML email templates
*/
function booking_update_7250() {
/*
* Add fields for this:
Up to 3 instances of
- link text
- link URL
Up to 4 instances of
- social media title
- social media icon URL
- social media link
*/
$booking_mailtemplate_fields = array(
'fields' => array(
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
'booking_mailtemplate_media_type' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
'booking_mailtemplate_link_title' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
'booking_mailtemplate_icon_url' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
'booking_mailtemplate_link_url' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
'booking_mailtemplate_link_active' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
),
'primary key' => array('mid'),
);
db_create_table('booking_mailtemplate_fields', $booking_mailtemplate_fields);
//update the view to match the new table definition
_booking_node_create_mysqlview();
}
/**
* Implementation of hook_install().
*/

View File

@@ -0,0 +1,127 @@
<?php
/**
* Function to allow admin user to define parameters for HTML emails that can be sent by Bookings module
*
* @param
* @return form render array
*/
function booking_mailtemplate_form($node, &$form_state) {
global $event;
$form = array();
$header_link_max_count = 3;
$social_media_link_max_count = 5;
$prefix = "<h2>Configure HTML email template</h2>";
//query for existing header links
$query = db_select('booking_mailtemplate_fields', 'm');
$query->condition('m.booking_mailtemplate_media_type', 'header', '=');
$query->fields('m');
$header_links = $query->execute()->fetchAllAssoc('mid');
//query for existing social media links
$query = db_select('booking_mailtemplate_fields', 'm');
$query->condition('m.booking_mailtemplate_media_type', 'socialmedia', '=');
$query->fields('m');
$social_media_links = $query->execute()->fetchAllAssoc('mid');
$form['booking_mailtemplate_background_color'] = array (
'#type' => 'textfield',
'#title' => t('Background Colour'),
'#description' => t('Specify CSS compatible value'),
'#size' => 10,
'#maxlength' => 50,
'#default_value' => variable_get('booking_mailtemplate_background_color','#FFFFFF'),
);
$form['booking_mailtemplate_content_background_color'] = array (
'#type' => 'textfield',
'#title' => t('Content area Background Colour'),
'#description' => t('Specify CSS compatible value'),
'#size' => 10,
'#maxlength' => 50,
'#default_value' => variable_get('booking_mailtemplate_content_background_color','#FFFFFF'),
);
$form['booking_mailtemplate_header_background_color'] = array (
'#type' => 'textfield',
'#title' => t('Header area Background Colour'),
'#description' => t('Specify CSS compatible value'),
'#size' => 10,
'#maxlength' => 50,
'#default_value' => variable_get('booking_mailtemplate_header_background_color','#FFFFFF'),
);
$form['booking_mailtemplate_text_color'] = array (
'#type' => 'textfield',
'#title' => t('Text Colour'),
'#description' => t('Specify CSS compatible value'),
'#size' => 10,
'#maxlength' => 50,
'#default_value' => variable_get('booking_mailtemplate_text_color','#FFFFFF'),
);
$form['booking_mailtemplate_link_color'] = array (
'#type' => 'textfield',
'#title' => t('Link Colour'),
'#description' => t('Specify CSS compatible value'),
'#size' => 10,
'#maxlength' => 50,
'#default_value' => variable_get('booking_mailtemplate_link_color','#FFFFFF'),
);
$form['booking_mailtemplate_header_image_url'] = array (
'#type' => 'textfield',
'#title' => t('URL of header image'),
'#description' => t('Specify full URL to image used in header'),
'#size' => 150,
'#maxlength' => 500,
'#default_value' => variable_get('booking_mailtemplate_header_image_url', $GLOBALS['base_url'] . '/sites/all/modules/booking/images/logo.png'),
);
$form['booking_mailtemplate_header_link_url'] = array (
'#type' => 'textfield',
'#title' => t('Destination URL for header'),
'#description' => t('Specify full URL to direct user if they click on header image'),
'#size' => 150,
'#maxlength' => 500,
'#default_value' => variable_get('booking_mailtemplate_header_link_url', $GLOBALS['base_url']),
);
$form['header-links'] = array(
'#type' => 'fieldset',
'#title' => 'Header Links',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//add form elements for header links
for ($i = 1; $i <= $header_link_max_count; $i++) {
$header_link_text = 'booking_mailtemplate_headerlink_text' . $i;
$header_link_url = 'booking_mailtemplate_headerlink_url' . $i;
$form['header-links'][$header_link_text] = array(
'#type' => 'textfield',
'#title' => t('Display text for header link ' . $i),
'#size' => 150,
'#maxlength' => 300,
'#default_value' => variable_get($header_link_text,'Link Title'),
);
$form['header-links'][$header_link_url] = array(
'#type' => 'textfield',
'#title' => t('URL for header link ' . $i),
'#size' => 150,
'#maxlength' => 500,
'#default_value' => variable_get($header_link_url,'Link URL'),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return array (
'first_para' => array (
'#type' => 'markup',
'#markup' => $prefix,
),
'form' => $form,
);
}

View File

@@ -752,8 +752,21 @@ function booking_menu() {
'access arguments' => array('access administration pages'),
'file' => 'booking.earlyaccess_admin.inc',
'type' => MENU_LOCAL_ACTION,
);
);
//manage HTML email template if enabled
if (variable_get('booking_enable_html_mail', 0) == 1)) {
$items['admin/config/booking/mailtemplate'] = array(
'title' => 'Booking module HTML email',
'description' => 'Configure the look of HTMl emails for the Booking module',
'page callback' => 'drupal_get_form',
'page arguments' => array('booking_mailtemplate_form'),
'access arguments' => array('access administration pages'),
'file' => 'booking.mailtemplate_admin.inc',
'type' => MENU_NORMAL_ITEM,
);
}
//the paypal IPN
$items[BOOKING_PAYPAL_IPN_PATH] = array(
'type' => MENU_CALLBACK,