mailtemplate stored as json in variable table

This commit is contained in:
2017-09-15 15:00:28 +10:00
parent 19978d51f5
commit 8f1319c79a
4 changed files with 101 additions and 20 deletions

View File

@@ -13,7 +13,12 @@
$social_media_link_max_count = 5;
$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 (
@@ -164,4 +170,35 @@
),
'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
}