? support_anonymous.patch
? support_anonymous2.patch
Index: support.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/support/support.admin.inc,v
retrieving revision 1.2.2.19
diff -u -p -r1.2.2.19 support.admin.inc
--- support.admin.inc	22 Apr 2010 07:21:57 -0000	1.2.2.19
+++ support.admin.inc	4 Nov 2010 21:29:57 -0000
@@ -301,7 +301,7 @@ function support_admin_settings() {
   );
   $form['general']['support_autoassign_ticket'] = array(
     '#type' => 'textfield',
-    '#autocomplete_path' => 'support/autocomplete/assigned',
+    '#autocomplete_path' => 'support/autocomplete/assigned/0',
     '#title' => t('Auto-assign new tickets to'),
     '#description' => t('Enter a username to autoassign new tickets to a specific user (the user must have %admin permissions). Enter %creator to autoassign new tickets to the user creating the ticket. Leave blank or enter %nobody to leave new tickets unassigned. This value can be overridden on a per-client basis.', array('%admin' => t('administer support'), '%creator' => '<' . t('creator') .'>', '%nobody' => '<' . t('nobody') .'>')),
     '#default_value' => variable_get('support_autoassign_ticket', '<nobody>'),
Index: support.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/support/support.install,v
retrieving revision 1.3.2.8
diff -u -p -r1.3.2.8 support.install
--- support.install	19 Apr 2010 00:04:20 -0000	1.3.2.8
+++ support.install	4 Nov 2010 21:29:57 -0000
@@ -170,6 +170,12 @@ function support_schema() {
         'unsigned' => TRUE,
         'default' => 0,
       ),
+      'anonymous_email' => array(
+        'description' => t('Email address associated with a ticket submitted by an unauthenticated user.'),
+        'type' => 'varchar',
+        'length' => '64',
+        'not null' => FALSE,
+      ),
     ),
     'primary key' => array('nid'),
     'indexes' => array(
@@ -479,3 +485,18 @@ function support_update_6005() {
   return array();
 }
 
+/**
+ * Introduce "anonymous_email" field to support anonymous tickets.
+ */
+function support_update_6006() {
+  $ret = array();
+  db_add_field($ret, 'support_ticket', 'anonymous_email',
+    array(
+      'type' => 'varchar',
+      'length' => '64',
+      'not null' => FALSE,
+      'description' => 'Email address associated with a ticket submitted by an unauthenticated user.',
+    )
+  );
+  return $ret;
+}
Index: support.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/support/support.module,v
retrieving revision 1.3.2.67
diff -u -p -r1.3.2.67 support.module
--- support.module	5 Sep 2010 08:12:03 -0000	1.3.2.67
+++ support.module	4 Nov 2010 21:29:57 -0000
@@ -543,7 +543,16 @@ function support_form(&$node) {
     '#default_value' => !empty($node->title) ? $node->title : NULL,
     '#weight' => -5,
   );
-
+  global $user;
+  if ($user->uid === 0 || (user_access('edit any ticket') && $node->uid === '0')) {
+    $form['anonymous_email'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Email address'),
+      '#required' => TRUE,
+      '#default_value' => !empty($node->anonymous_email) ? $node->anonymous_email : NULL,
+      '#weight' => -1,
+    );
+  }
   $reference = array();
   $form = array_merge($form, support_status_form($reference, $node, ''));
 
@@ -595,7 +604,7 @@ function support_nodeapi(&$node, $op, $t
         drupal_set_breadcrumb($breadcrumb);
         break;
       case 'load':
-        return db_fetch_array(db_query('SELECT message_id, state, priority, client, assigned FROM {support_ticket} WHERE nid = %d', $node->nid));
+        return db_fetch_array(db_query('SELECT message_id, state, priority, client, assigned, anonymous_email FROM {support_ticket} WHERE nid = %d', $node->nid));
       case 'validate':
         $client = db_result(db_query('SELECT name FROM {support_client} WHERE clid = %d', $node->client));
         if (!isset($node->client) || $node->client == 0) {
@@ -657,9 +666,9 @@ function support_nodeapi(&$node, $op, $t
             $node->assigned = 0;
           }
         }
-        db_query("UPDATE {support_ticket} SET message_id = '%s', state = %d, priority = %d, client = %d, assigned = %d WHERE nid = %d", isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned, $node->nid);
+        db_query("UPDATE {support_ticket} SET message_id = '%s', state = %d, priority = %d, client = %d, assigned = %d, anonymous_email = '%s' WHERE nid = %d", isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned, $node->anonymous_email, $node->nid);
         if (!db_affected_rows()) {
-          db_query("INSERT INTO {support_ticket} (nid, message_id, state, priority, client, assigned) VALUES(%d, '%s', %d, %d, %d, %d)", $node->nid, isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned);
+          db_query("INSERT INTO {support_ticket} (nid, message_id, state, priority, client, assigned, anonymous_email) VALUES(%d, '%s', %d, %d, %d, %d, '%s')", $node->nid, isset($node->message_id) ? $node->message_id : '', $node->state, $node->priority, $node->client, $node->assigned, $node->anonymous_email);
         }
         if ($op == 'insert') {
           if (isset($node->notifications) && !empty($node->notifications)) {
@@ -1392,8 +1401,12 @@ function support_notification($comment =
     $result = db_query('SELECT uid FROM {support_assigned} WHERE nid = %d AND active = 1', $nid);
     while ($account = db_fetch_object($result)) {
       $account = user_load(array('uid' => $account->uid));
+      if (!$account->mail) {
+        $ticket = node_load($nid);
+      }
+      $address = $account->mail ? $account->mail : $ticket->anonymous_email;
       // always send emails to admins, even if update was suppressed
-      if ($account->mail && (!$suppress || user_access('administer support', $account))) {
+      if ($address && (!$suppress || user_access('administer support', $account))) {
         _support_mail_notify($op, $account, $comment, $nid, $suppress);
         if (variable_get('support_admin_notify', FALSE)) {
           if ((variable_get('support_admin_notify', FALSE) == 1 && user_access('administer support')) || variable_get('support_admin_notify', FALSE) == 2) {
@@ -1401,7 +1414,7 @@ function support_notification($comment =
           }
         }
       }
-      else if (!$account->mail) {
+      else if ($address) {
         watchdog('support', 'User !name (!uid) has no email address.', array('!name' => $account->name, '!uid' => $account->uid), WATCHDOG_NOTICE);
       }
     }
@@ -1443,7 +1456,8 @@ function _support_mail_notify($op, $acco
     else {
       $mailfrom = variable_get('support_global_mailfrom', '');
     }
-    $mail = drupal_mail('support', $op, $account->mail, $language, $params, $mailfrom);
+    $address = $account->mail ? $account->mail : $node->anonymous_email;
+    $mail = drupal_mail('support', $op, $address, $language, $params, $mailfrom);
     // TODO: notify admins as necessary
   }
   return empty($mail) ? NULL : $mail['result'];
@@ -1456,7 +1470,7 @@ function _support_comment_update_node($n
   $cid = db_result(db_query('SELECT MAX(cid) FROM {comments} WHERE nid = %d', $nid));
   if ($cid) {
     $comment = db_fetch_object(db_query('SELECT state, priority, client, assigned FROM {support_ticket_comment} WHERE cid = %d', $cid));
-    db_query('UPDATE {support_ticket} SET state = %d, priority = %d, client = %d, assigned = %d WHERE nid = %d', $comment->state, $comment->priority, $comment->client, $comment->assigned, $nid);
+    db_query('UPDATE {support_ticket} SET state = %d, priority = %d, client = %d, assigned = %d, WHERE nid = %d', $comment->state, $comment->priority, $comment->client, $comment->assigned, $nid);
   }
 }
 
@@ -2504,7 +2518,11 @@ function support_page_form(&$form_state,
     $form['id'][$ticket->nid] = array('#value' => l($ticket->nid, "node/$ticket->nid", array('attributes' => array('class' => 'ticket-id'))));
     $form['title'][$ticket->nid] = array('#value' => l(_support_truncate($ticket->title), "node/$ticket->nid", array('attributes' => array('class' => 'ticket-title'))));
     $form['updated'][$ticket->nid] = array('#value' => format_date($ticket->last_updated, 'small', array('attributes' => array('class' => 'ticket-updated'))));
-    $form['reported'][$ticket->nid] = array('#value' => l(_support_truncate($account->name, 24), "user/$account->uid", array('attributes' => array('class' => 'ticket-reported'))));
+    if ($account->uid === '0') {
+      $form['reported'][$ticket->nid] = array('#value' => 'anonymous');
+    } else {
+      $form['reported'][$ticket->nid] = array('#value' => l(_support_truncate($account->name, 24), "user/$account->uid", array('attributes' => array('class' => 'ticket-reported'))));
+    }
     // Assigned to
     if ((user_access('edit multiple tickets') && user_access('can assign tickets to any user')) || user_access('administer support')) {
       $node = node_load($ticket->nid);
