Index: contrib/forward/feedback-forward-email.tpl.php
===================================================================
--- contrib/forward/feedback-forward-email.tpl.php (revision 0)
+++ contrib/forward/feedback-forward-email.tpl.php (revision 0)
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+'
\ No newline at end of file
Index: contrib/forward/feedback_forward.info
===================================================================
--- contrib/forward/feedback_forward.info (revision 0)
+++ contrib/forward/feedback_forward.info (revision 0)
@@ -0,0 +1,5 @@
+; $Id: feedback.info,v 1.5 2008/10/15 08:23:30 sun Exp $
+name = Feedback Forward
+description = Allows site administrators to forward feedback messages to one or more email addresses.
+package = Development
+core = 6.x
\ No newline at end of file
Index: contrib/forward/feedback_forward.module
===================================================================
--- contrib/forward/feedback_forward.module (revision 0)
+++ contrib/forward/feedback_forward.module (revision 0)
@@ -0,0 +1,161 @@
+ 'Forward feedback message',
+ 'description' => 'Forward feedback message.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('feedback_forward_form', 4),
+ 'access arguments' => array('forward feedback messages'),
+ );
+ return $items;
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function feedback_forward_form_alter(&$form, $form_state, $form_id) {
+ // Add the node-type settings option to activate the email this page link
+ if ($form_id == 'feedback_admin_view_form') {
+ $form['#feedback_header'][] = t('Forward');
+ }
+ foreach (element_children($form['feedback-messages-0']) as $element) {
+ $item = &$form['feedback-messages-0'][$element];
+ $item['forward_link'] = array(
+ '#value' => l('Forward', 'admin/reports/feedback/forward/'. $element, array('title'=> 'Forward this feedback message', 'query' => drupal_get_destination())),
+ );
+ }
+}
+
+/**
+ * Form builder function for a user feedback form.
+ */
+function feedback_forward_form($form, $feedbacks) {
+ $form = array();
+ if ($feedbacks) {
+ $output = '';
+ foreach ($feedbacks as $feedback) {
+ $headers = array(t('Property'), t('Value'));
+ $rows[] = array(
+ array('data' => t('Location'), 'header' => TRUE, 'style' => 'text-align:right',),
+ l(truncate_utf8($feedback->location, 32, FALSE, TRUE), $feedback->location)
+ );
+ $rows[] = array(
+ array('data' => t('Date'), 'header' => TRUE, 'style' => 'text-align:right',),
+ format_date($feedback->timestamp, 'small')
+ );
+ $rows[] = array(
+ array('data' => t('User'), 'header' => TRUE, 'style' => 'text-align:right',),
+ theme('username', $feedback)
+ );
+ $rows[] = array(
+ array('data' => t('Message'), 'header' => TRUE, 'style' => 'text-align:right',),
+ feedback_format_message($feedback)
+ );
+ $output .= theme('table', $headers, $rows);
+ $form['message_markup'] = array(
+ '#value' => $output,
+ );
+ $form['user'] = array(
+ '#type' => 'hidden',
+ '#value' => theme('username', $feedback),
+ );
+ $form['date'] = array(
+ '#type' => 'hidden',
+ '#value' => format_date($feedback->timestamp, 'small')
+ );
+ $form['message'] = array(
+ '#type' => 'hidden',
+ '#value' => $output,
+ );
+ }
+ }
+ $form['email'] = array(
+ '#type' => 'textfield',
+ '#title' => 'Email address',
+ '#description' => 'Details of this feedback message will be e-mailed to this address. Multiple e-mail addresses may be separated by commas.',
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => 'Send',
+ );
+ return $form;
+}
+
+/**
+ * Form validation.
+ */
+function feedback_forward_form_validate(&$form, $form_state) {
+ // Ensure the entered e-mail addresses are valid.
+ if (!empty($form_state['values']['email'])) {
+ $emails = explode(',', $form_state['values']['email']);
+ foreach ($emails as $email) {
+ if (!valid_email_address(trim($email))) {
+ form_set_error('email', t('The entered email address %address is not a valid address.', array('%address' => $email)));
+ break;
+ }
+ }
+ }
+}
+
+/**
+ * Form submission.
+ */
+function feedback_forward_form_submit(&$form, $form_state) {
+ global $base_url, $user;
+ $vars = array(
+ 'site_name' => variable_get('site_name', 'Drupal'),
+ 'forward_message' => t('Message:'),
+ 'message' => $form_state['values']['message'],
+ 'base_url' => $base_url,
+ 'path' => 'path_here',
+ 'dynamic_content' => 'dynamic_content',
+ );
+ $params['body'] = theme('feedback_forward_email', $vars);
+ $params['subject'] = t('!name has forwarded you site feedback from !site', array('!name' => $user->name, '!site' => variable_get('site_name', 'drupal')));
+ $params['from'] = $form_state['values']['email'];
+ $recipients = explode(',', $form_state['values']['email']);
+ foreach ($recipients as $to) {
+ drupal_mail('feedback_forward', 'feedback_forward', $to, language_default(), $params, $params['from']);
+ }
+}
+
+/**
+ * Implementation of hook_mail().
+ */
+function feedback_forward_mail($key, &$message, $params) {
+ $message['from'] .= $params['from'];
+ $message['subject'] .= $params['subject'];
+ $message['body'][] = $params['body'];
+ $message['headers']['MIME-Version'] = '1.0';
+ $message['headers']['Content-Type'] = 'text/html; charset=utf-8';
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function feedback_forward_theme() {
+ return array(
+ 'feedback_forward_email' => array(
+ 'arguments' => array('vars' => NULL),
+ 'template' => 'feedback-forward-email',
+ ),
+ );
+}
\ No newline at end of file
Index: feedback.module
===================================================================
--- feedback.module (revision 331)
+++ feedback.module (working copy)
@@ -104,10 +104,10 @@
);
if (user_access('view feedback messages')) {
if (arg(0) != 'node') {
- $feedbacks = feedback_load(array('status' => 0, 'location_masked' => feedback_mask_path($_GET['q'])));
+ $feedbacks = feedback_load(NULL, array('status' => 0, 'location_masked' => feedback_mask_path($_GET['q'])));
}
else {
- $feedbacks = feedback_load(array('status' => 0, 'location' => $_GET['q']));
+ $feedbacks = feedback_load(NULL, array('status' => 0, 'location' => $_GET['q']));
}
if ($feedbacks) {
$rows = '';
@@ -171,10 +171,15 @@
/**
* Load feedback entries from the database.
*
+ * @param $fid
+ * An optional fid of a specific feedback message to load.
* @param $array
* A keyed array of optional where clause conditions.
*/
-function feedback_load($array) {
+function feedback_load($fid = NULL, $array = array()) {
+ if ($fid) {
+ $array['fid'] = $fid;
+ }
$where = $args = array();
if (!empty($array)) {
foreach ($array as $column => $value) {
@@ -301,15 +306,13 @@
// Build the table.
$rows = array();
foreach (element_children($item) as $element_entry) {
+ //die(dpr($element_entry));
$entry = &$item[$element_entry];
// Render the data first.
- $rows[] = array(
- 0,
- drupal_render($entry['location']),
- drupal_render($entry['date']),
- drupal_render($entry['user']),
- drupal_render($entry['message']),
- );
+ $rows[] = array(0);
+ foreach (element_children($entry) as $column) {
+ $rows[count($rows) - 1][] = drupal_render($entry[$column]);
+ }
// Render the checkbox.
$rows[count($rows) - 1][0] = drupal_render($entry);
}