test meta tokens

This commit is contained in:
Nathan Coad
2018-06-16 21:53:17 +10:00
parent 6f971767f0
commit 5fe2d8d88d
3 changed files with 67 additions and 22 deletions

View File

@@ -707,15 +707,28 @@ function booking_admin() {
'#description' => t('Select database fields to export to CSV. Ensure you hold down control/command when selecting multiple options.'), '#description' => t('Select database fields to export to CSV. Ensure you hold down control/command when selecting multiple options.'),
'#options' => $booking_view_fields, '#options' => $booking_view_fields,
'#default_value' => variable_get('booking_export_include_fields_dynamic', ''), '#default_value' => variable_get('booking_export_include_fields_dynamic', ''),
); );
$form['management']['booking_import_include_fields_dynamic'] = array( $form['management']['booking_import_include_fields_dynamic'] = array(
'#type' => 'select', '#type' => 'select',
'#multiple' => TRUE, '#multiple' => TRUE,
'#title' => t('Not In Use - Select database fields'), '#title' => t('Not In Use - Select database fields'),
'#description' => t('Select database fields to import from an uploaded CSV file. Ensure you hold down control/command when selecting multiple options.'), '#description' => t('Select database fields to import from an uploaded CSV file. Ensure you hold down control/command when selecting multiple options.'),
'#options' => $booking_view_fields, '#options' => $booking_view_fields,
'#default_value' => variable_get('booking_import_include_fields_dynamic', ''), '#default_value' => variable_get('booking_import_include_fields_dynamic', ''),
); );
$form['meta-tokens'] = array(
'#type' => 'fieldset',
'#title' => 'Meta Token Definitions',
'#collapsible' => TRUE,
);
$form['meta-tokens']['booking_studygroup_summary_li_text'] = array (
'#type' => 'textfield',
'#title' => t('Study Group Summary Format'),
'#default_value' => variable_get('booking_studygroup_summary_li_text',
'<b>[meta-booking:studygroup-role]</b> for group <b>[meta-booking:studygroup-descrip]</b>, which will occur on <b>[meta-booking:studygroup-weekday]</b>. <b>[meta-booking:studygroup-explan]</b>'),
'#description' => 'List element definition (using tokens) for study group summary in emails.',
);
//return system_settings_form($form); //return system_settings_form($form);
//make sure we update our custom sql view every time we change something on the admin page //make sure we update our custom sql view every time we change something on the admin page

View File

@@ -1630,6 +1630,16 @@ function _booking_studygroup_email_summary($node) {
if (!empty($node->$sessionid)) { if (!empty($node->$sessionid)) {
//$rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid)); //$rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid));
$tokens = array(
'studygroup-descrip' => $studygroup->booking_studygroup_descrip,
'studygroup-weekday' => $studygroup->booking_studygroup_weekday,
'studygroup-explan' => $studygroup->booking_studygroup_explanation,
'studygroup-role' => _booking_studygroup_role_lookup($node->$roleid),
);
$li_text = variable_get('booking_studygroup_summary_li_text', '');
$rows[] = token_replace($li_text, $tokens);
/*
// Add some boldness if we're using html email // Add some boldness if we're using html email
if(variable_get('booking_enable_html_mail', 0) == 1) { if(variable_get('booking_enable_html_mail', 0) == 1) {
$rows[] = t('<b>!role</b> for group <b>!descrip</b>, which will occur on <b>!weekday</b>. <b>!explan</b>', array( $rows[] = t('<b>!role</b> for group <b>!descrip</b>, which will occur on <b>!weekday</b>. <b>!explan</b>', array(
@@ -1644,6 +1654,7 @@ function _booking_studygroup_email_summary($node) {
'!explan' => $studygroup->booking_studygroup_explanation, '!role' => _booking_studygroup_role_lookup($node->$roleid), '!explan' => $studygroup->booking_studygroup_explanation, '!role' => _booking_studygroup_role_lookup($node->$roleid),
)); ));
} }
*/
} // End checking for empty studygroup session } // End checking for empty studygroup session
} // End foreach loop } // End foreach loop

View File

@@ -510,6 +510,28 @@ function booking_token_info() {
'name' => t('Travel form Link'), 'name' => t('Travel form Link'),
'description' => t('Link to the person\'s travel form.') 'description' => t('Link to the person\'s travel form.')
); );
$info['types']['meta-booking'] = array(
'name' => t('Meta Booking Tokens'),
'description' => t('Sub-tokens for the booking module that are used by other booking module tokens. They will only work in a very limited context.'),
'needs-data' => 'booking',
);
$info['tokens']['meta-booking']['studygroup-descrip'] = array(
'name' => t('Study Group Description'),
'description' => t('Used in the studygroup-summary token.')
);
$info['tokens']['meta-booking']['studygroup-weekday'] = array(
'name' => t('Study Group Weekday'),
'description' => t('Used in the studygroup-summary token.')
);
$info['tokens']['meta-booking']['studygroup-explan'] = array(
'name' => t('Study Group Explanation'),
'description' => t('Used in the studygroup-summary token.')
);
$info['tokens']['meta-booking']['studygroup-role'] = array(
'name' => t('Study Group Role'),
'description' => t('Used in the studygroup-summary token.')
);
return $info; return $info;
} }
@@ -542,7 +564,7 @@ function booking_tokens($type, $tokens, array $data = array(), array $options =
$replacements = array(); $replacements = array();
$sanitize = !empty($options['sanitize']); $sanitize = !empty($options['sanitize']);
if ($type == 'booking') { if ($type == 'booking' || $type == 'meta-booking') {
foreach ($tokens as $name => $original) { foreach ($tokens as $name => $original) {
if (array_key_exists($name, $data)) { if (array_key_exists($name, $data)) {
$replacements[$original] = $data[$name]; $replacements[$original] = $data[$name];
@@ -646,7 +668,6 @@ function booking_define_personspecific_tokens($node)
$tokens['confirm-payment-link'] = url('confirm/' . $tempid, array('absolute' => TRUE)); $tokens['confirm-payment-link'] = url('confirm/' . $tempid, array('absolute' => TRUE));
} }
//if payment processor is set to manual then don't populate these tokens //if payment processor is set to manual then don't populate these tokens
//if paypal is enabled //if paypal is enabled
if ($payment_processor_type == 0) { if ($payment_processor_type == 0) {