mailtemplate stored as json in variable table
This commit is contained in:
@@ -1,5 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to put together all the information for theming a HTML based email, if enabled
|
||||
*
|
||||
* @param
|
||||
* @return themed message text
|
||||
*/
|
||||
function _booking_generate_html_body($subject, $body, $tokens) {
|
||||
global $event;
|
||||
$output_text = "";
|
||||
|
||||
//Check if we should apply a HTML theme to the email text or just send a normal email
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
//get the footer text
|
||||
$message_footer = variable_get('booking_html_mail_footer');
|
||||
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
|
||||
$message_footer = token_replace($message_footer, $tokens);
|
||||
|
||||
$colors = json_decode(variable_get('booking_mailtemplate_colors'), TRUE);
|
||||
$header_links = json_decode(variable_get('booking_mailtemplate_header_links'), TRUE);
|
||||
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
|
||||
|
||||
$output_text = theme('booking_htmlmail_registration_mail',
|
||||
array(
|
||||
'module' => 'booking',
|
||||
'key' => 'registration_mail',
|
||||
'body' => $body,
|
||||
'subject' => $subject,
|
||||
'footer' => $message_footer,
|
||||
'colors' => $colors,
|
||||
'header_links' => $header_links,
|
||||
'social_links' => $social_links,
|
||||
));
|
||||
}
|
||||
else {
|
||||
$output_text = $body;
|
||||
}
|
||||
|
||||
watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($output_text, true)));
|
||||
return $output_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send email to registrant after completing registration process
|
||||
*
|
||||
@@ -41,6 +82,11 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
||||
}
|
||||
$params['subject'] = $subject;
|
||||
|
||||
$raw_body = _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual);
|
||||
$themed_body = _booking_generate_html_body($subject, $raw_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
/*
|
||||
//get the footer text
|
||||
$message_footer = variable_get('booking_html_mail_footer');
|
||||
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
|
||||
@@ -64,6 +110,7 @@ function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
||||
$body = _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual);
|
||||
$params['body'] = $body;
|
||||
}
|
||||
*/
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
|
@@ -737,20 +737,10 @@ function booking_update_7249() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create table to store configuration for HTML email templates
|
||||
* Deprecated - 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
|
||||
*/
|
||||
function booking_update_7250() {
|
||||
$booking_mailtemplate_fields = array(
|
||||
'fields' => array(
|
||||
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -768,6 +758,7 @@ function booking_update_7250() {
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
|
@@ -14,6 +14,11 @@
|
||||
|
||||
$prefix = "<h2>Configure HTML email template</h2>";
|
||||
|
||||
$colors = json_decode(variable_get('booking_mailtemplate_colors'), TRUE);
|
||||
$header_links = json_decode(variable_get('booking_mailtemplate_header_links'), TRUE);
|
||||
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
|
||||
|
||||
/*
|
||||
//query for existing header links
|
||||
$query = db_select('booking_mailtemplate_fields', 'm');
|
||||
$query->condition('m.booking_mailtemplate_media_type', 'header', '=');
|
||||
@@ -25,6 +30,7 @@
|
||||
$query->condition('m.booking_mailtemplate_media_type', 'socialmedia', '=');
|
||||
$query->fields('m');
|
||||
$social_media_links = $query->execute()->fetchAllAssoc('mid');
|
||||
*/
|
||||
|
||||
$form['colors'] = array(
|
||||
'#type' => 'fieldset',
|
||||
@@ -38,7 +44,7 @@
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => variable_get('booking_mailtemplate_background_color','#FFFFFF'),
|
||||
'#default_value' => empty($colors['booking_mailtemplate_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_content_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -46,7 +52,7 @@
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => variable_get('booking_mailtemplate_content_background_color','#FFFFFF'),
|
||||
'#default_value' => empty($colors['booking_mailtemplate_content_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_content_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_header_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -54,7 +60,7 @@
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => variable_get('booking_mailtemplate_header_background_color','#FFFFFF'),
|
||||
'#default_value' => empty($colors['booking_mailtemplate_header_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_header_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_text_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -62,7 +68,7 @@
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => variable_get('booking_mailtemplate_text_color','#FFFFFF'),
|
||||
'#default_value' => empty($colors['booking_mailtemplate_text_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_text_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_link_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -70,7 +76,7 @@
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => variable_get('booking_mailtemplate_link_color','#FFFFFF'),
|
||||
'#default_value' => empty($colors['booking_mailtemplate_link_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_link_color'],
|
||||
);
|
||||
|
||||
$form['booking_mailtemplate_header_image_url'] = array (
|
||||
@@ -165,3 +171,34 @@
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_mailtemplate_form_submit($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$colors_variable_list = array('booking_mailtemplate_background_color', 'booking_mailtemplate_content_background_color',
|
||||
'booking_mailtemplate_header_background_color', 'booking_mailtemplate_text_color', 'booking_mailtemplate_link_color',
|
||||
);
|
||||
$header_links_variable_list = array();
|
||||
$social_links_variable_list = array();
|
||||
|
||||
$color_data = array();
|
||||
$header_data = array();
|
||||
$social_data = array();
|
||||
// 'booking_mailtemplate_header_image_url', 'booking_mailtemplate_header_link_url');
|
||||
|
||||
//set all the values that are just using the builtin drupal variable definitions
|
||||
foreach ($values as $key => $value) {
|
||||
if (in_array($key, $colors_variable_list, FALSE)) {
|
||||
//variable_set($key, $value);
|
||||
$color_data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
variable_set('booking_mailtemplate_colors', json_encode($color_data));
|
||||
|
||||
//update header links
|
||||
|
||||
//update social media links
|
||||
|
||||
}
|
@@ -895,9 +895,15 @@ function booking_theme($existing, $type, $theme, $path) {
|
||||
'template' => 'mimemail-message' // extension of .tpl.php automatically added
|
||||
),
|
||||
'booking_htmlmail_registration_mail' => array(
|
||||
'variables' => array('subject' => NULL, 'body' => NULL, 'footer' => NULL, 'links' => NULL),
|
||||
'variables' => array('subject' => NULL,
|
||||
'body' => NULL,
|
||||
'footer' => NULL,
|
||||
'colors' => NULL,
|
||||
'header_links' => NULL,
|
||||
'social_links' => NULL
|
||||
),
|
||||
'path' => $theme_path,
|
||||
'image_path' => drupal_get_path('module', 'booking'). '/images',
|
||||
//'image_path' => drupal_get_path('module', 'booking'). '/images',
|
||||
'template' => $template_file,
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user