Index: ecard.module
===================================================================
--- ecard.module	(revision 836)
+++ ecard.module	(working copy)
@@ -78,6 +78,11 @@
     '#size' => '5',
     '#default_value' => variable_get('ecard_max_count', '100'),
   );
+  $form['settings']['ecard_thank_you_page'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Path to thank you page'),
+    '#default_value' => variable_get('ecard_thank_you_page', 'ecard/thanks'), '#description' => t('Enter the path to the thank you page where users should be redirected to after sending an e-card.  For example, <em>ecard/thanks</em>, <em>node/123</em>.  Leave blank for no redirection.'),
+  );
   $form['settings']['ecard_hide_send_view'] = array(
     '#type' => 'checkbox',
     '#title' => t('Hide the send e-card form when viewing the e-card message.'),
@@ -144,12 +149,17 @@
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
   );
+  $form['copy']['ecard_copy_enabled'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Send a copy of e-cards to sender'),
+    '#default_value' => variable_get('ecard_copy_enabled', TRUE),
+  );
   $form['copy']['ecard_copy_subject'] = array(
     '#type' => 'textfield',
     '#title' => t('Subject'),
     '#default_value' => variable_get('ecard_copy_subject', 'Copy of your e-card'),
     '#size' => 70,
-    '#maxlenghth' => 70,
+    '#maxlength' => 70,
     '#description' => t('Customize email sent to sender with copy of card.'),
   );
   $form['copy']['ecard_copy'] = array(
@@ -167,6 +177,11 @@
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
   );
+  $form['notify']['ecard_notify_enabled'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable option for card collection notification emails'),
+    '#default_value' => variable_get('ecard_notify_enabled', TRUE),
+  );
   $form['notify']['ecard_notify_subject'] = array(
     '#type' => 'textfield',
     '#title' => t('Subject'),
@@ -284,12 +299,16 @@
   );
   // Filter format for the text.
   $form['filter'] = filter_form();
+
   // Notification on pick up.
-  $form['notify']=array(
-    '#type' => 'checkbox',
-    '#title' => t('Notify me when the card is picked up'),
-    '#default_value' => 0
-  );
+  if (variable_get('ecard_notify_enabled', TRUE)) {
+    $form['notify'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Notify me when the card is picked up'),
+      '#default_value' => 0
+    );
+  }
+
   $form['nid'] = array(
     '#type' => 'value',
     '#value' => $node->nid
@@ -377,46 +396,42 @@
   while (!$random) {
     $random = md5(microtime());
     $result = db_fetch_object(db_query("SELECT random FROM {ecard} WHERE random = '%s'", $random));
-    if ($result) unset($random);
+    if ($result) {
+      unset($random);
+    }
   }
   $card_copy_url = $base .'ecard/view/'. $random;
 
-  $sql = 'INSERT INTO {ecard} (random, nid, sender_name, sender_email, recp_mail, message, send_time, send, notify, format)
-    VALUES ("%s", %d, "%s", "%s", "%s", "%s", %d, "%s", "%s", %d)';
+  // Making a copy for you else if you click any other recp link it will mail
+  // notification also there is some problem while we produce random.
+  $record = new stdClass;
+  $record->random = $random;
+  $record->nid = $form_state['values']['nid'];
+  $record->sender_name = $form_state['values']['name'];
+  $record->sender_email = $form_state['values']['from_email'];
+  $record->recp_mail = $form_state['values']['from_email'];
+  $record->message = $form_state['values']['message'];
+  $record->send_time = $timestamp;
+  $record->send = $send;
+  $record->notify = $notify;
+  $record->format = $form_state['values']['format'];
+  drupal_write_record('ecard', $record);
 
-  //making a copy for you else if you click any other recp link it will mail notification also there is some problem while we produce random
-  db_query($sql,
-    $random,
-    $form_state['values']['nid'],
-    $form_state['values']['name'],
-    $form_state['values']['from_email'],
-    $form_state['values']['from_email'],
-    $form_state['values']['message'],
-    $timestamp,
-    $send,
-    $notify,
-    $form_state['values']['format']
-  );
   $cardid = $random;
 
-  //iterate through each emails and send them and store a random number for each
+  // Iterate through each emails and send them and store a random number for
+  // each.
   foreach ($form_state['values']['valid_emails'] as $email) {
-    if ($form_state['values']['notify'] == 1) {
+    if (variable_get('ecard_notify_enabled', TRUE) && $form_state['values']['notify'] == 1) {
       $notify = "y";
-      $cardid = $random . $start;//append start value to random number to get cardid
-      $start = $start + 1; // making some number in increment order
-      db_query($sql,
-        $cardid,
-        $form_state['values']['nid'],
-        $form_state['values']['name'],
-        $form_state['values']['from_email'],
-        $email,
-        $form_state['values']['message'],
-        $timestamp,
-        $send,
-        $notify,
-        $form_state['values']['format']
-      );
+      // Append start value to random number to get cardid.
+      $cardid = $random . $start;
+      // Making some number in increment order.
+      $start = $start + 1;
+
+      $record->random = $cardid;
+      $record->recp_mail = $email;
+      drupal_write_record('ecard', $record);
     }
     $params['card'] = $base .'ecard/view/'. $cardid;
     $params['sender'] = $form_state['values']['name'];
@@ -424,10 +439,16 @@
     $params['recipient'] = $email;
     drupal_mail('ecard', 'ecard-mail', $email, $language, $params, $form_state['values']['from_email']);
   }
-  drupal_set_message(t("Your message has been sent and a copy is stored for your reference.<br />you can view the copy <a href='") . $card_copy_url . t("'>here</a>"));
-  $params['card_copy'] = $card_copy_url;
-  drupal_mail('ecard', 'ecard-copy', $form_state['values']['from_email'], $language, $params, variable_get('site_mail', ini_get('sendmail_from')));
-  $form_state['redirect'] = 'ecard/thanks';
+  drupal_set_message(format_plural(count($form_state['values']['valid_emails']), 'Your e-card has been sent.', 'Your e-cards have been sent.'));
+  if (variable_get('ecard_copy_enabled', TRUE)) {
+    drupal_set_message(t('You can view the e-card at <a href="') . $card_copy_url . t('">here</a>.'));
+    $params['card_copy'] = $card_copy_url;
+    drupal_mail('ecard', 'ecard-copy', $form_state['values']['from_email'], $language, $params, variable_get('site_mail', ini_get('sendmail_from')));
+  }
+  $thank_you_page = variable_get('ecard_thank_you_page', 'ecard/thanks');
+  if (!empty($thank_you_page)) {
+    $form_state['redirect'] = $thank_you_page;
+  }
   $form_state['nid'] = $node->nid;
 }
 
@@ -492,7 +513,7 @@
       $output = node_view($node, FALSE, TRUE, FALSE);
 
       // Sending email if notify == yes.
-      if ($result->notify == y) {
+      if ($result->notify == 'y') {
         $card_url = $base .'ecard/view/'. $result->random;
 
         // Make message.
@@ -502,7 +523,7 @@
         $params['sender'] = $result->sender_name;
         $params['recipient'] = $result->recp_mail;
         $params['sender_email'] = $result->sender_email;
-        drupal_mail('ecard', 'ecard-view', $params['sender_email'], NULL, $params, $site_email);
+        drupal_mail('ecard', 'ecard-notify', $params['sender_email'], NULL, $params, $site_email);
         db_query("UPDATE {ecard} SET notify='n' WHERE random='%s'", $result->random);
       }
     }
@@ -551,7 +572,7 @@
       $message['body'] = $body;
       break;
 
-    case 'ecard-view':
+    case 'ecard-notify':
       $variables = array(
         '%site' => variable_get('site_name', 'drupal'),
         '%site_url' => $base_url,
@@ -562,7 +583,7 @@
         '%sender_email' => $params['sender_email'],
       );
       $body = strtr(variable_get('ecard_notify', _ecard_notify()), $variables);
-      $subject = strtr(variable_get('notify_subject', 'Your card has been picked up by %recipient'), $variables);
+      $subject = strtr(variable_get('ecard_notify_subject', 'Your card has been picked up by %recipient'), $variables);
       $message['subject'] = $subject;
       $message['body'] = $body;
       break;
