From ed45d52007bd2fda6a2faf9029ed66d486002495 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Sat, 16 Jun 2018 18:39:55 +1000 Subject: [PATCH] add more detail to study group definitions and email token --- booking.emails.inc | 12 ++++++------ booking.helper.inc | 20 ++++++++++++++------ booking.install | 15 ++++++++++++++- booking.module | 10 +++++----- booking.studygroups_admin.inc | 20 ++++++++++++++++++-- 5 files changed, 57 insertions(+), 20 deletions(-) diff --git a/booking.emails.inc b/booking.emails.inc index 148e9fe..7171c6a 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -328,12 +328,12 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') { '!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from'))) )); // Test email attachments with dummy file - $attachment = array( - 'filecontent' => file_get_contents(DRUPAL_ROOT . '/README.txt'), - 'filename' => 'test.txt', - 'filemime' => 'text/plain', - ); - $params['attachment'] = $attachment; + //$attachment = array( + // 'filecontent' => file_get_contents(DRUPAL_ROOT . '/README.txt'), + // 'filename' => 'test.txt', + // 'filemime' => 'text/plain', + //); + //$params['attachment'] = $attachment; } //load the node matching this id diff --git a/booking.helper.inc b/booking.helper.inc index 5ad3fef..a4c3080 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -1620,16 +1620,18 @@ function _booking_studygroup_email_summary($node) { $studygroups = $studygroups_query->fetchAllAssoc('sid'); //for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++) - foreach ($studygroups as $studygroup) - { + foreach ($studygroups as $studygroup) { //calculate the session references $sessionid = "session" . $studygroup->sid; $roleid = $sessionid . "_role"; //check that this study group session has been defined for this attendee - if (!empty($node->$sessionid)) - { - $rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid)); + if (!empty($node->$sessionid)) { + //$rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid)); + $rows[] = t('!role for group !descrip, which will occur on !weekday. !explan', array( + '!descrip' => $studygroup->booking_studygroup_descrip, '!weekday' => $studygroup->booking_studygroup_weekday, + '!explan' => $studygroup->booking_studygroup_explanation, '!role' => _booking_studygroup_role_lookup($node->$roleid), + )); } } } @@ -1639,7 +1641,13 @@ function _booking_studygroup_email_summary($node) { } if(variable_get('booking_enable_html_mail', 0) == 1) { - return implode("\n
", $rows); + $output = "\n\n"; + //return implode("\n
", $rows); + return $output; } else { return implode("\n", $rows); diff --git a/booking.install b/booking.install index 5623872..692d852 100644 --- a/booking.install +++ b/booking.install @@ -800,6 +800,17 @@ function booking_update_7255() { _booking_node_create_mysqlview(); } +/** +* Add fields for study group definitions +*/ +function booking_update_7256() { + $spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE); + db_add_field('booking_studygroup_list', 'booking_studygroup_weekday', $spec); + db_add_field('booking_studygroup_list', 'booking_studygroup_explanation', $spec); + //update the view to match the new table definition + _booking_node_create_mysqlview(); +} + /** * Implementation of hook_install(). */ @@ -1118,13 +1129,15 @@ function booking_schema() { ), 'primary key' => array('tid'), ); - + //This lists all the study groups $schema['booking_studygroup_list'] = array( 'fields' => array( 'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_studygroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_studygroup_weekday' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_studygroup_explanation' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), 'booking_num_group_sessions' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 1), 'booking_is_readinggroup' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), ), diff --git a/booking.module b/booking.module index 7a470e9..cd443c6 100644 --- a/booking.module +++ b/booking.module @@ -976,11 +976,11 @@ function booking_mail($key, &$message, $params) { // Add attachment when available. // From https://drupal.stackexchange.com/questions/101035/send-attachments-with-drupal-mail - if (isset($params['attachment'])) { - $message['params']['attachments'][] = $params['attachment']; - } + //if (isset($params['attachment'])) { + // $message['params']['attachments'][] = $params['attachment']; + //} - watchdog('booking_debug', "
Mail hook:\n@info
", array('@info' => print_r( $message, true))); + //watchdog('booking_debug', "
Mail hook:\n@info
", array('@info' => print_r( $message, true))); } /** @@ -1011,7 +1011,7 @@ function booking_mail_alter(&$message) { foreach($headers as $key => $value) { $message['headers'][$key] = $value; } - //watchdog('booking_debug', "
Mail alter hook:\n@info
", array('@info' => print_r( $message, true))); + watchdog('booking_debug', "
Mail alter hook:\n@info
", array('@info' => print_r( $message, true))); } /** diff --git a/booking.studygroups_admin.inc b/booking.studygroups_admin.inc index b4cd5ca..abf1de5 100644 --- a/booking.studygroups_admin.inc +++ b/booking.studygroups_admin.inc @@ -112,14 +112,30 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid = } if(!isset($form_state['storage']['confirm'])) { + $form['booking_studygroup_weekday'] = array ( + '#type' => 'textfield', + '#title' => t('Day of the week this study group will be held (eg Monday)'), + '#size' => 60, + '#maxlength' => 150, + '#required' => TRUE, + '#default_value' => !empty($data->booking_studygroup_weekday) ? $data->booking_studygroup_weekday : '', + ); $form['booking_studygroup_descrip'] = array ( '#type' => 'textfield', - '#title' => t('Description of this study group (eg Monday)'), + '#title' => t('Description of this study group (eg Study Group 1)'), '#size' => 60, '#maxlength' => 150, '#required' => TRUE, '#default_value' => !empty($data->booking_studygroup_descrip) ? $data->booking_studygroup_descrip : '', - ); + ); + $form['booking_studygroup_explanation'] = array ( + '#type' => 'textfield', + '#title' => t('Explanation for this study group (eg Matthew chapter 1)'), + '#size' => 60, + '#maxlength' => 150, + '#required' => TRUE, + '#default_value' => !empty($data->booking_studygroup_explanation) ? $data->booking_studygroup_explanation : '', + ); $form['booking_num_group_sessions'] = array ( '#type' => 'textfield',