### Eclipse Workspace Patch 1.0
#P faq_ask
Index: faq_ask.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq_ask/faq_ask.module,v
retrieving revision 1.17.2.23.2.14
diff -u -r1.17.2.23.2.14 faq_ask.module
--- faq_ask.module	22 Oct 2009 04:11:46 -0000	1.17.2.23.2.14
+++ faq_ask.module	20 Mar 2010 20:33:03 -0000
@@ -61,7 +61,7 @@
   else {
 //    return user_access('answer question') || user_access('edit_own_faq');
     // We don't include "edit own" because the intent is they can edit their own until it's published.
-    return user_access('answer question') || $account->uid == $node->uid; 
+    return user_access('answer question') || $account->uid == $node->uid;
   }
 }
 
@@ -133,7 +133,7 @@
  * Get the ask question form.
  */
 function faq_ask_page($tid = NULL) {
-  drupal_goto('node/add/faq', 'ask=true');
+  drupal_goto('node/add/faq', 'ask=TRUE');
 }
 
 /**
@@ -148,7 +148,7 @@
     if ($user->uid == $node->uid) {
 //      $form = drupal_get_form('faq_ask_form', NULL, $node);
 //      return $form;
-      drupal_goto("node/$node->nid/edit", 'ask=true');
+      drupal_goto("node/$node->nid/edit", 'ask=TRUE');
     }
     else {
       drupal_set_message(t('You are not allowed to edit that question.'), 'error');
@@ -165,7 +165,7 @@
   if ($form_id != 'faq_node_form' || !isset($_GET['ask'])) {
       return;
     }
-  if ($_GET['ask'] != 1 && $_GET['ask'] != 'true') {
+  if ($_GET['ask'] != 1 && $_GET['ask'] != 'TRUE' && $_GET['ask'] != 'true') {
     return;
   }
 
@@ -183,9 +183,148 @@
   }
   $form['body'] = array('#type' => 'value', '#value' => variable_get('faq_ask_unanswered', t('Not answered yet.')));
 
+  // if we're supposed to notify asker on answer, add form item for this
+  if (variable_get('faq_ask_notify_asker', FALSE)) {
+
+    global $user;
+
+    // If asker is anonymous, add an optional e-mail field that may be used for notification when question is answered
+    if ($user->uid == 0) {
+      // Form field for e-mail.
+      $form['faq-email'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Notification E-mail (optional)'),
+        '#default_value' => '',
+        '#weight' => 0,
+        '#description' => t('Write your e-mail here if you would like to be notified when the question is answered.')
+        );
+    }
+    else {
+      // Checkbox for notification
+      $form['faq-notify'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Notify by E-mail (optional)'),
+        '#default_value' => FALSE,
+        '#weight' => 0,
+        '#description' => t('Check this box if you would like to be notified when the question is answered.'),
+        );
+    }
+  }
+
+  // Add validation of the e-mail field
+  if (isset($form['#validate'])) {
+    $temp_val = $form['#validate'];
+    $form['#validate'] = array($temp_val);
+  }
+  else {
+    $form['#validate'] = array();
+  }
+  $form['#validate'][] = 'faq_ask_form_validate';
+
   // Make sure we know we came from here.
   $form['faq_ask'] = array('#type' => 'value', '#value' => TRUE);
-  $form['#submit'][] = 'faq_ask_submit';
+  $form['buttons']['submit']['#submit'][] = 'faq_ask_submit';
+
+  // Sean Corales: Redirect to faq page if user is anonymous or cannot edit own faq nodes
+  global $user;
+  if ((!user_access('edit own faq') && !user_access('edit faq')) || ($user->uid == 0)) {
+    $form['#redirect'] = 'faq';
+  }
+
+  // Handle special cases if this is a block form
+  if (isset($_GET['block'])) {
+    if ($_GET['block']) {
+
+      // Shorten the description text on taxonomy field
+      if (!variable_get('faq_ask_categorize', FALSE) && isset($form['taxonomy']['tags'])) {
+        $tags = array_keys($form['taxonomy']['tags']);
+        $form['taxonomy']['tags'][$tags[0]]['#description'] = t('A comma-separated list of terms.');
+      }
+      else {
+        unset($form['taxonomy']);
+      }
+
+      // Shorter description on Qestion field + move it higher
+      $form['title']['#description'] = t('Question to be answered.');
+      $form['title']['#weight'] = '-5';
+
+      // Shorter description on detailed question field
+      $form['detailed_question']['#description'] = t('Longer question text.');
+
+    }
+  }
+}
+
+/**
+ * Validation form for the FAQ Ask form
+ * Thanks to http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/
+ */
+function faq_ask_form_validate($form, &$form_state) {
+
+  if (isset($form_state['values']['faq-email'])) {
+    $email = $form_state['values']['faq-email'];
+    if (strlen($email) > 1 && !eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $email)) {
+      form_set_error('email', t('That is not a valid e-mail address.'));
+    }
+  }
+}
+
+/**
+ * Implementation of hook_nodeapi().
+ *
+ * Checks if the node being updated is a question that has been answered
+ */
+function faq_ask_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  if ($node->type == 'faq') {
+    switch ($op) {
+      case 'update':
+
+        // return if the asker notification should be done by cron
+        if (variable_get('faq_ask_notify_by_cron', TRUE)) {
+          return;
+        }
+
+        // Check if the node is published and asker notified
+        $email = _faq_ask_get_faq_notification_email($node->nid);
+        if ($node->status == '1' && $email != '') {
+          // Get the asker account
+          $account = user_load(array('mail' => $email));
+          // If the account is not anonymous
+          if ($account) {
+            $params['account'] = $account;
+          }
+          else {
+            $params['account'] = NULL;
+          }
+
+          $params['question'] = $node->title;
+          $params['nid'] = $node->nid;
+
+          // Send the e-mail to the asker. Drupal calls hook_mail() via this
+          $mail_sent = drupal_mail('faq_ask', 'notify_asker', $email, user_preferred_language($params['account']), $params);
+
+          // Handle sending result
+          if ($mail_sent) {
+            watchdog('FAQ_Ask', 'Asker notification email sent to @to for question @quest',
+              array('@to' => $email, '@quest' => check_plain($node->title)), WATCHDOG_NOTICE);
+              // If email sent, remove the notification from the queue
+              _faq_ask_delete_faq_notification($node->nid);
+          }
+          else {
+            watchdog('FAQ_Ask', 'Asker notification email to @to failed for the "@quest" question.',
+              array('@to' => $email, '@quest' => check_plain($node->title)), WATCHDOG_ERROR);
+            drupal_set_message( t( 'Asker notification email to @to failed for the "@quest" question.',
+              array('@to' => $email, '@quest' => check_plain($node->title))
+                )
+              );
+          }
+        }
+        break;
+
+      default:
+        break;
+    }
+  }
 }
 
 function faq_ask_submit($form, &$form_state) {
@@ -202,12 +341,13 @@
   else {
     $category = 0;  // 0 is default expert.
   }
+
   // Are we notifying the expert(s)?
   if (variable_get('faq_ask_notify', FALSE)) {
     $params = array(
       'category' => $category ? $category : -1,
-      'question' => $node->title,
-      'nid' => $node->nid,
+      'question' => $form_state['values']['title'],
+      'nid' => $form_state['nid'],
       'creator' => theme('username', $node, array('plain' => TRUE)),
       );
     // Find out who the experts are.
@@ -228,10 +368,172 @@
     }
   }
 
-  drupal_set_message(t('Your question has been submitted. It will appear in the FAQ listing as soon as it has been answered.'), 'status');
+  // Handle the notification of asker
+  if (isset($form_state['values']['faq-email']) && strlen($form_state['values']['faq-email']) > 4) { // length of e-mail must be more than a@b.c
+    _faq_ask_set_faq_notification($form_state['nid'], $form_state['values']['faq-email']);
+    drupal_set_message(t('Your question has been submitted. An e-mail will be sent to <i>@mail</i> when answered.', array('@mail' => $form_state['values']['faq-email'])), 'status');
+
+    // If this user is not registered as a user before - check if all asking anonymous users should be added to the newsletter list
+    if (module_exists('simplenews') && $tid = variable_get('faq_ask_notify_asker_simplenews_tid', '0')) {
+      // If we have selected a newsletter to add
+      if (function_exists('simplenews_subscribe_user')) {
+        simplenews_subscribe_user($form_state['values']['faq-email'], $tid,  variable_get('faq_ask_notify_asker_simplenews_confirm', 1), 'FAQ-Ask');
+      }
+    }
+  }
+  elseif (isset($form_state['values']['faq-notify'])) {
+    if ($form_state['values']['faq-notify']) {
+      global $user;
+      $email = $user->mail;
+      _faq_ask_set_faq_notification($form_state['nid'], $email);
+      drupal_set_message(t('Your question has been submitted. An e-mail will be sent to <i>@mail</i> when answered.', array('@mail' => $email)), 'status');
+    }
+  }
+  else {
+    drupal_set_message(t('Your question has been submitted. It will appear in the FAQ listing as soon as it has been answered.'), 'status');
+  }
 }
 
 /**
+ * Implementation of hook_cron().
+ *
+ * Checks the que for asker notifications and sends a notification to the asker when the question is published
+ *
+ */
+function faq_ask_cron() {
+
+  // If the asker notification should be done by cron
+  if (!variable_get('faq_ask_notify_by_cron', TRUE)) {
+    return;
+  }
+  // Get all the waiting notifications
+  $notifications = _faq_ask_get_faq_notifications();
+  foreach ($notifications as $nid => $email) {
+    // With the notification record, check if status of the question is published
+    if ($result = db_query('SELECT title,status FROM {node} WHERE nid=%d', $nid)) {
+      $notification = db_fetch_array($result);
+      if ($notification['status'] == '1') {
+
+      $params = array(
+        'question' => $notification['title'],
+        'nid' => $nid,
+        'account' => user_load(array('mail' => $email)),
+        );
+
+        // Send the e-mail to the asker. Drupal calls hook_mail() via this
+        $mail_sent = drupal_mail('faq_ask', 'notify_asker', $email, user_preferred_language($params['account']), $params);
+
+        // Handle sending result
+        if ($mail_sent) {
+          watchdog('FAQ_Ask', 'Asker notification email sent to @to for question: "@quest"',
+            array('@to' => $email, '@quest' => check_plain($notification['title'])), WATCHDOG_NOTICE);
+            // If email sent, remove the notification from the queue
+            _faq_ask_delete_faq_notification($nid);
+        }
+        else {
+          watchdog('FAQ_Ask', 'Asker notification email to @to failed for the "@quest" question.',
+            array('@to' => $email, '@quest' => check_plain($notification['title'])), WATCHDOG_ERROR);
+          drupal_set_message(t('Asker notification email to @to failed for the "@quest" question.', array('@to' => $email, '@quest' => check_plain($notification['title']))));
+        }
+      }
+    }
+
+  }
+}
+/**
+ * Helper function to fetch an email for notification assigned to an faq node
+ *
+ */
+function _faq_ask_get_faq_notification_email($nid) {
+  if ($nid != '') {
+    $result = db_query('SELECT email FROM {faq_ask_notify} WHERE nid=%d', $nid);
+    $mail = db_fetch_array($result);
+    return $mail['email'];
+  }
+  else {
+    return '';
+  }
+}
+
+/**
+ * Helper function fetching all notifications
+ * returns: Array containing all outstanding notifications
+ */
+function _faq_ask_get_faq_notifications() {
+  $notifications = array();
+
+  $result = db_query('SELECT nid, email FROM {faq_ask_notify}');
+  while ($row = db_fetch_array($result)) {
+    $notifications[$row['nid']] = $row['email'];
+  }
+  return $notifications;
+
+}
+function _faq_ask_set_faq_notification($nid, $email) {
+
+  $data = array(
+    'nid' => $nid,
+    'email' => $email
+  );
+  drupal_write_record('faq_ask_notify', $data);
+}
+
+function _faq_ask_delete_faq_notification($nid) {
+  $delete = db_query("DELETE FROM {faq_ask_notify} WHERE nid=%d", $nid);
+  if ($delete === FALSE) {
+    drupal_set_message(t('Attempt to delete email notification failed.'), 'error');
+  }
+}
+
+
+
+/**
+ * Block "Ask a Question" form implementation
+ * This implements the form displayed in a block where the user may ask a question
+ *
+ */
+function faq_ask_a_question_blockform() {
+
+  // Include page handler for node_add()
+  module_load_include('inc', 'node', 'node.pages');
+
+  // If user is allowed to create a faq content type
+  if (node_access('create', 'faq')) {
+
+    // Fool the hook_form_alter function to think we're in an faq-ask page
+    $saved_get = '';
+    if (isset($_GET['ask'])) {
+      $saved_get = $_GET['ask'];
+    }
+    $_GET['ask'] = '1';
+    $_GET['block'] = 'TRUE';
+
+    // Note title before rendering of form.
+    $title = drupal_get_title();
+    // Create the form
+    $form = node_add('faq');
+    // Restore title, which will have been overridden.
+    drupal_set_title($title);
+
+    // Restore the $_GET['ask'] variable status
+    if ($saved_get != '') {
+      $_GET['ask'] = $saved_get;
+    }
+    else {
+      unset($_GET['ask']);
+    }
+    unset($_GET['block']);
+
+    return $form;
+  }
+  else {
+    return '';
+  }
+
+}
+
+
+/**
  * Implementation of hook_mail().
  * This function completes the email, allowing for placeholder substitution.
  * @TODO: notify_asker.
@@ -248,7 +550,7 @@
       $variables = array_merge($variables, array(
         '!cat' => $params['category'],
         '@question' => $params['question'],
-        '!answer_uri' => url('faq_ask/answer/'. $params['nid'], array('absolute' => TRUE)),
+        '!answer_uri' => url('faq_ask/unanswered', array('absolute' => TRUE)),
         '!asker' => $params['creator'],
         ));
 
@@ -260,9 +562,27 @@
       else {
         $body[] = t('The following question has been posted in the "!cat" category by !asker.', $variables, $language->language);
       }
-      $body[] = $params['question'];
+      $body[] = t('<i>@question</i>', $variables, $language->language);
       $body[] = t('In order to answer it you will first need to <a href="!login_uri">login</a> to the site.', $variables, $language->language);
-      $body[] = t('Once logged in, you may proceed <a href="!answer_uri">directly to the question</a> to answer it.', $variables, $language->language);
+      $body[] = t('Once logged in, you may proceed <a href="!answer_uri">directly to the list of unanswered questions</a> to select and answer it.', $variables, $language->language);
+      break;
+
+    case 'notify_asker':
+      $variables = array_merge($variables, array(
+        '!cat' => $params['category'],
+        '@question' => $params['question'],
+        '!question_uri' => url('node/'. $params['nid'], array('absolute' => TRUE)),
+        ));
+
+      if ($variables['!username'] == '') {
+        $variables['!username'] = t('user');
+      }
+
+      $subject = t('A question you asked has been answered on !site', $variables, $language->language);
+      $body[] = t('Dear !username,', $variables, $language->language);
+      $body[] = t('The question: "@question" you asked on !site has been answered.', $variables, $language->language);
+      $body[] = t('To view the answer, please visit the question you created on !question_uri.', $variables, $language->language);
+      $body[] = t('Thank you for visiting.', $variables, $language->language);
       break;
   }
   $message['body'] = drupal_wrap_mail(implode($newline, $body));
@@ -296,6 +616,22 @@
   // Get the admin's name.
   $admin = ucwords(db_result(db_query('SELECT name FROM {users} WHERE uid=1')));
 
+  // Get the Simplenews newsletters if they exists
+  $newsletters = array('0' => t('No newsletter'));
+
+  if (module_exists('simplenews')) {
+    if (!function_exists('simplenews_get_newsletters')) {
+      drupal_set_message(t('The Simplenews integration is not compatible with this version of Simplenews. Please download a later version.'), 'error');
+    }
+    else {
+      $list = simplenews_get_newsletters(variable_get('simplenews_vid', ''));
+      foreach ($list as $key => $object) {
+        $list[$key] = $object->name;
+      }
+      $newsletters += $list;
+    }
+  }
+
   $form['notification'] = array(
     '#type' => 'fieldset',
     '#title' => t('Notifications'),
@@ -310,6 +646,46 @@
     '#default_value' => variable_get('faq_ask_notify', 0),
     );
 
+  $form['notification']['notify_asker'] = Array(
+    '#type' => 'fieldset',
+    '#title' => T('Asker notification'),
+    '#collapsible' => FALSE,
+    '#collapsed' => FALSE,
+    );
+
+  $form['notification']['notify_asker']['faq_ask_asker_notify'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Notify askers'),
+    '#description' => t('If this box is checked, the asker creating the question will be notified via email that their question is answered.'),
+    '#default_value' => variable_get('faq_ask_notify_asker', 0),
+    );
+
+  $form['notification']['notify_asker']['faq_ask_asker_notify_cron'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use cron for asker notification'),
+    '#description' => t('If this box is checked, the asker notifications will be sendt via cron.'),
+    '#default_value' => variable_get('faq_ask_notify_by_cron', TRUE),
+    '#disabled' =>  !variable_get('faq_ask_notify_asker', 0),
+    );
+
+  // If the Simplenews module is loaded we can add functionality to add anonymous askers to a newsletter
+  $form['notification']['notify_asker']['faq_ask_notify_asker_simplenews'] = array(
+    '#type' => 'select',
+    '#title' => t('Add anonymous asker to newsletter'),
+    '#default_value' => variable_get('faq_ask_notify_asker_simplenews_tid', '0'),
+    '#options' => $newsletters,
+    '#description' => (module_exists('simplenews') ? t('Select a newsletter you want anonymous askers to be assigned to.') : t('This functionality needs the <a href="http://drupal.org/project/simplenews">Simplenews module</a> to be activated.')),
+    '#disabled' => !module_exists('simplenews'),
+     );
+
+  $form['notification']['notify_asker']['faq_ask_notify_asker_simplenews_confirm'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Confirm subscription to newsletter'),
+    '#description' => t('If this box is checked, the asker creating the question will be asked to confirm the subscription of the newsletter.'),
+    '#default_value' => variable_get('faq_ask_notify_asker_simplenews_confirm', 1),
+    '#disabled' => !module_exists('simplenews'),
+    );
+
   $form['options'] = array(
     '#type' => 'fieldset',
     '#title' => t('Options'),
@@ -345,7 +721,7 @@
     '#description' => t('This text will be inserted into the body of questions when they are asked. This helps make editing easier'),
     '#default_value' => variable_get('faq_ask_unanswered', t('Not answered yet.')),
     );
- 
+
   $form['options']['faq_ask_expert_advice'] = array(
     '#type' => 'textarea',
     '#title' => t('Answer advice for the expert'),
@@ -434,7 +810,7 @@
   //$vocabs = variable_get('faq_ask_vocabularies', $def_vid);
   $vocabs_array = array();
   foreach ($vocabs as $vocab) {
-    $vocabs_array[$vocab->vid] = $vocab->vid;  
+    $vocabs_array[$vocab->vid] = $vocab->vid;
   }
 
   $result = db_query('SELECT td.tid, td.name, td.description FROM {term_data} td WHERE td.vid IN ('. db_placeholders($vocabs_array) .') ORDER BY td.weight ASC, td.name ASC', $vocabs_array);
@@ -566,7 +942,7 @@
     else {
       // Expert 0 means default expert; overlook it.
       if ($expert['tid'] != 0) {
-        drupal_set_message(t("!name doesn't exist. If you have just changed your role selections this may be okay.", array('!name' => $box_name)), 'warning'); 
+        drupal_set_message(t("!name doesn't exist. If you have just changed your role selections this may be okay.", array('!name' => $box_name)), 'warning');
       }
     }
   }
@@ -590,7 +966,7 @@
   }
 
   // Get rid of error element.
-  unset($form['error']);  
+  unset($form['error']);
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save configuration'),
@@ -615,6 +991,10 @@
   variable_set('faq_ask_categorize', $form_state['values']['faq_ask_categorize']);
   variable_set('faq_ask_expert_own', $form_state['values']['faq_ask_expert_own']);
   variable_set('faq_ask_notify', $form_state['values']['faq_ask_notify']);
+  variable_set('faq_ask_notify_asker', $form_state['values']['faq_ask_asker_notify']);
+  variable_set('faq_ask_notify_asker_simplenews_tid', $form_state['values']['faq_ask_notify_asker_simplenews']);
+  variable_set('faq_ask_notify_asker_simplenews_confirm', $form_state['values']['faq_ask_notify_asker_simplenews_confirm']);
+  variable_set('faq_ask_notify_by_cron', $form_state['values']['faq_ask_asker_notify_cron']);
   variable_set('faq_ask_unanswered', $form_state['values']['faq_ask_unanswered']);
   variable_set('faq_ask_default_expert', $form_state['values']['faq_ask_default_expert']);
   variable_set('faq_ask_expert_advice', $form_state['values']['faq_ask_expert_advice']);
@@ -652,7 +1032,7 @@
   global $user;
   // Validate the request.
   if (!isset($_REQUEST['token']) || !drupal_valid_token($_REQUEST['token'], "faq_ask/answer/$node->nid")) {
-    watchdog('Faq_Ask', 
+    watchdog('Faq_Ask',
       'Received an invalid answer request (@query_string) from @user_ip.',
       array('@query_string' => $_SERVER['QUERY_STRING'], '@user_ip' => $_SERVER['REMOTE_ADDR']),
       WATCHDOG_ALERT);
@@ -694,6 +1074,7 @@
 
 /**
  * Implementation of hook_taxonomy().
+ *
  *  @param:
  *    op:  'insert', 'update, 'delete'
  *    type: 'term', 'vocabulary'
@@ -797,7 +1178,7 @@
   global $user;
   $name = check_plain($edit['name']);
   $uname = $user->name;
-  drupal_set_message("Vocabulary '$name' is being removed from the Faq_Ask list.", 'status');
+  drupal_set_message(t("Vocabulary '@name' is being removed from the Faq_Ask list.", array('@name' => $name)), 'status');
   watchdog('Faq_Ask', 'Vocabulary @voc was deleted from Faq_Ask by @name.', array('@voc' => $name, '@name' => $uname), WATCHDOG-NOTICE);
   unset($my_vocs[$vid]);
   variable_set('faq_ask_vocabularies', $my_vocs);
@@ -844,11 +1225,13 @@
 }
 
 /**
- *  Implementation of hook_block().
- *  This creates and populates the "unanswered questions" block.
+ * Implementation of hook_block().
+ *
+ * This creates and populates the "unanswered questions" block.
  */
 function faq_ask_block($op = 'list', $delta = 0, $edit = array()) {
   global $user;
+  $block = array();
   switch ($op) {
     case 'list':
       $blocks[0]['info'] = t('Unanswered Questions');
@@ -865,7 +1248,8 @@
         case 1:
           // Ask a question block.
           if (user_access('ask question')) {
-            $block['content'] = faq_ask_page(NULL);
+            $block['title']= t('Ask a Question');
+            $block['content'] = faq_ask_a_question_blockform();
           }
 
       } // end switch($delta).
@@ -912,7 +1296,7 @@
   // What permissions does this user have?
   $can_edit = user_access('administer faq') || user_access('administer nodes');
   $is_expert = user_access('answer question');
-  
+
   $mode = 'edit';
   $output = $extra_msg = NULL;
   // A high limit means we are doing the "unanswered" page.
@@ -985,7 +1369,7 @@
     $token = drupal_get_token('faq_ask/answer/'. $node['nid']);
     $options = array('query' => "token=$token");
     if ($mode == 'edit') {
-      $options['query'] .= '&ask=true';
+      $options['query'] .= '&ask=TRUE';
     }
     if ($prev_cat == $tid || $limit < 1000) {
       $items[] = ($limit < 1000) ?
Index: faq_ask.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/faq_ask/faq_ask.install,v
retrieving revision 1.4.2.7
diff -u -r1.4.2.7 faq_ask.install
--- faq_ask.install	24 Nov 2008 20:13:07 -0000	1.4.2.7
+++ faq_ask.install	20 Mar 2010 20:33:01 -0000
@@ -32,6 +32,28 @@
       'tid' => array('tid', 'uid'),
       ),
     );
+
+  $schema['faq_ask_notify'] = array(
+    'description' => t('FAQ node to asker mapping.'),
+    'fields' => array(
+      'nid' => array(
+        'description' => t('Node identifier for notification'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        ),
+      'email' => array(
+        'description' => t('Node identifier for notification'),
+        'type' => 'varchar',
+        'length' => '128',
+        'not null' => TRUE,
+        ),
+      ),
+    'primary key' => array('nid', 'email'),
+    'indexes' => array(
+      'nid' => array('nid', 'email'),
+      ),
+    );
   return $schema;
 }
 
@@ -42,10 +64,10 @@
   $result = drupal_install_schema('faq_ask');
 
   if (count($result) > 0) {
-    drupal_set_message(t('faq_ask module installed.'));
+    drupal_set_message(st('faq_ask module installed.'));
   }
   else {
-    drupal_set_message(t('faq_ask table creation failed. Please "uninstall" the module and retry.'));
+    drupal_set_message(st('faq_ask table creation failed. Please "uninstall" the module and retry.'));
   }
 }
 
@@ -55,11 +77,22 @@
 function faq_ask_update_6100() {
   $ret = array();
 
-  $ret[] = update_sql('INSERT INTO {faq_expert} (uid, tid) VALUES ('. variable_get('faq_ask_default_expert', 1) .', 0)'); 
+  $ret[] = update_sql('INSERT INTO {faq_expert} (uid, tid) VALUES ('. variable_get('faq_ask_default_expert', 1) .', 0)');
+
+  return $ret;
+}
+
+function faq_ask_update_6101() {
+
+  $ret = array();
+  $schema = faq_ask_schema();
+  db_create_table($ret, 'faq_ask_notify', $schema['faq_ask_notify']);
 
   return $ret;
+
 }
 
+
 /**
  * Implementation of hook_uninstall().
  */
@@ -77,6 +110,10 @@
   variable_del('faq_ask_help_text');
   variable_del('faq_ask_categorize');
   variable_del('faq_ask_expert_own');
-  
-  drupal_set_message(t('faq_ask module uninstalled.'));
+  variable_del('faq_ask_notify_asker');
+  variable_del('faq_ask_notify_asker_simplenews_tid');
+  variable_del('faq_ask_notify_asker_simplenews_confirm');
+  variable_del('faq_ask_notify_by_cron');
+
+  drupal_set_message(st('faq_ask module uninstalled.'));
 }
