? .DS_Store
? views/.DS_Store
Index: multiple_email.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiple_email/multiple_email.module,v
retrieving revision 1.1.4.27
diff -u -p -r1.1.4.27 multiple_email.module
--- multiple_email.module	11 Jan 2011 05:17:25 -0000	1.1.4.27
+++ multiple_email.module	13 Jan 2011 05:08:13 -0000
@@ -63,6 +63,16 @@ function multiple_email_menu() {
     'type' => MENU_CALLBACK,
   );
 
+  $items['user/%user/edit/email-addresses/confirm/%multiple_email/resend'] = array(
+    'title' => t('Confirm Email Address'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('multiple_email_confirm_page_resend', 1, 5),
+    'access callback' => '_multiple_email_access',
+    'access arguments' => array('confirm', 1, 5),
+    'file' => 'multiple_email_confirm_page.inc',
+    'type' => MENU_CALLBACK,
+  );
+
   $items['user/%user/edit/email-addresses/primary/%multiple_email'] = array(
     'title' => t('Make E-mail Primary Address'),
     'page callback' => 'drupal_get_form',
Index: multiple_email.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiple_email/Attic/multiple_email.test,v
retrieving revision 1.1.2.12
diff -u -p -r1.1.2.12 multiple_email.test
--- multiple_email.test	11 Jan 2011 04:35:44 -0000	1.1.2.12
+++ multiple_email.test	13 Jan 2011 05:08:13 -0000
@@ -54,9 +54,38 @@ class MultipleEmailUserTestCase extends 
       }
     }
 
-    // Test confirming the new e-mail address.
-    $path = 'user/'. $this->loggedInUser->uid .'/edit/email-addresses/confirm/'. $address->eid .'/'. $address->confirm_code;
+    // Test that the confirmation e-mail was sent correctly.
+    $mail_params = array(
+      'subject' => multiple_email_message_part('subject', 'confirmation', $this->loggedInUser, $address),
+      'body' => multiple_email_message_part('body', 'confirmation', $this->loggedInUser, $address),
+    );
+    foreach ($mail_params as $name => $value) {
+      $this->assertMail($name, $value, t('Confirmation e-mail @name verified.', array('@name' => $name)));
+    }
 
+    // Resend the confirmation email
+    $this->drupalPost('user/'. $this->loggedInUser->uid .'/edit/email-addresses/confirm/'. $address->eid .'/resend', array(), t('Resend'));
+    $addresses = multiple_email_load_addresses($this->loggedInUser->uid);
+    array_shift($addresses);
+    foreach ($addresses as $address) {
+      if ($address->email == $edit['email']) {
+        break;
+      }
+    }
+
+    // Test that the confirmation e-mail was re-sent correctly.
+    $mail_params = array(
+      'subject' => multiple_email_message_part('subject', 'confirmation', $this->loggedInUser, $address),
+      'body' => multiple_email_message_part('body', 'confirmation', $this->loggedInUser, $address),
+    );
+    foreach ($mail_params as $name => $value) {
+      $this->assertMail($name, $value, t('Resent confirmation e-mail @name verified.', array('@name' => $name)));
+    }
+
+
+    // Get the path to the confirmation page.
+    $path = 'user/'. $this->loggedInUser->uid .'/edit/email-addresses/confirm/'. $address->eid .'/'. $address->confirm_code;
+    // Test confirming the new e-mail address.
     $this->drupalGet($path);
     $this->assertRaw(t('The e-mail address %email is awaiting confirmation. You should have received an e-mail at that address with a confirmation code in it. Enter the code below and click confirm.', array('%email' => $address->email)));
     $this->drupalPost($path, array(), t('Confirm'));
Index: multiple_email_confirm_page.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiple_email/multiple_email_confirm_page.inc,v
retrieving revision 1.1.4.11
diff -u -p -r1.1.4.11 multiple_email_confirm_page.inc
--- multiple_email_confirm_page.inc	11 Jan 2011 04:35:44 -0000	1.1.4.11
+++ multiple_email_confirm_page.inc	13 Jan 2011 05:08:14 -0000
@@ -24,13 +24,7 @@
 function multiple_email_confirm_page($account, $email, $code = NULL) {
   global $user;
   if (_multiple_email_access('confirm', $account, $email)) {
-    $check_confirm_deadline = time() - (variable_get('multiple_email_confirm_deadline', 5) * 24 * 60 * 60);
-    if ($email->time_code_generated < $check_confirm_deadline) {
-      // Send a confirmation e-mail if one has not been sent within the specified days.
-      $email->confirm_code = multiple_email_code();
-      db_query("UPDATE {multiple_email} SET confirm_code = '%s', time_code_generated = %d, attempts = 0 WHERE eid = %d", $email->confirm_code, time(), $email->eid);
-      multiple_email_send_confirmation($account, $email);
-    }
+
     menu_set_active_item('user/' . $account->uid . '/edit/email-addresses');
     return drupal_get_form('multiple_email_confirm_form', $account, $email, $code);
   }
@@ -58,22 +52,16 @@ function multiple_email_confirm_page($ac
 function multiple_email_confirm_form(&$form_state, $account, $email, $confirm_code) {
   $form = array();
 
-  $form['#redirect'] = 'user/' . $account->uid . '/edit/email-addresses';
-
   $form[] = array(
     '#type' => 'markup',
-    '#value' => '<p>' . t('The e-mail address %email is awaiting confirmation. You should have received an e-mail at that address with a confirmation code in it. Enter the code below and click confirm.', array('%email' => $email->email)) . '</p>',
-  );
-
-  $form['email'] = array(
-    '#type' => 'value',
-    '#value' => $email,
+    '#value' => '<p>' . t('The e-mail address %email is awaiting confirmation. You should have received an e-mail at that address with a confirmation code in it. Enter the code below and click confirm. If you have lost this e-mail or did not recieve a confirmation code you can try !resending it.', array(
+      '%email' => $email->email,
+      '!resending' => l(t('resending'), 'user/' . $account->uid . '/edit/email-addresses/confirm/' . $email->eid . '/resend'),
+    )) . '</p>',
   );
 
-  $form['account'] = array(
-    '#type' => 'value',
-    '#value' => $account,
-  );
+  $form['#email'] = $email;
+  $form['#account'] = $account;
 
   $form['code'] = array(
     '#type' => 'textfield',
@@ -82,6 +70,7 @@ function multiple_email_confirm_form(&$f
     '#default_value' => check_plain($confirm_code),
   );
 
+  $form['#redirect'] = 'user/' . $account->uid . '/edit/email-addresses';
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Confirm'),
@@ -93,8 +82,8 @@ function multiple_email_confirm_form(&$f
 function multiple_email_confirm_form_validate($form, &$form_state) {
   $code = trim($form_state['values']['code']);
 
-  $email = $form_state['values']['email'];
-  $account = $form_state['values']['account'];
+  $email = $form['#email'];
+  $account = $form['#account'];
 
   if ($code != '') {
     $attempts = $email->attempts + 1;
@@ -112,21 +101,64 @@ function multiple_email_confirm_form_val
       multiple_email_send_confirmation($account, $email);
 
       // Redirect & Message
-      form_set_error('', t('You have exhausted your allowed attempts at confirming this e-mail address. A new confirmation code has been sent.'));
+      drupal_set_message(t('You have exhausted your allowed attempts at confirming this e-mail address. A new confirmation code has been sent.'), 'error');
       drupal_goto('user/' . $account->uid . '/edit/email-addresses');
     }
   }
 }
 
 /**
- * Process multiple_email_confirm_form submission
+ * Process multiple_email_confirm_form submission.
  *
  * @param string $form_id
  * @param array $form_values
  */
 function multiple_email_confirm_form_submit($form, &$form_state) {
   // Confirmation successful!
-  $email = $form_state['values']['email'];
+  $email = $form['#email'];
   multiple_email_confirm_email($email);
   drupal_set_message(t('The address %email has been confirmed!', array('%email' => $email->email)));
 }
+
+/**
+ * Confirmation form for resending a confirmation code.
+ *
+ * @param array $form_state
+ * FormAPI state array.
+ * @param object $account
+ * Drupal user account object.
+ * @param object $email
+ * Multiple E-Mails email object.
+ */
+function multiple_email_confirm_page_resend(&$form_state, $account, $email) {
+  $msg = t('Please make sure that %email is correct typed. If not, please !delete it and add the correct address.', array(
+    '%email' => $email->email,
+    '!delete' => l(t('delete'), 'user/' . $account->uid . '/edit/email-addresses/delete/' . $email->eid),
+  ));
+
+  // TODO Should this redirect to the confirmation page or the address listing page?
+  $form['#redirect'] = 'user/' . $account->uid . '/edit/email-addresses/confirm/' . $email->eid;
+  $form['email'] = array(
+    '#type' => 'value',
+    '#value' => $email,
+  );
+
+  $form['account'] = array(
+    '#type' => 'value',
+    '#value' => $account,
+  );
+
+  return confirm_form($form, t('Resend confirmation to %email.', array('%email' => $email->email)), 'user/' . $account->uid . '/edit/email-addresses/confirm/' . $email->eid, $msg, t('Resend'));
+}
+
+/**
+ * Callback for resending a confirmation email.
+ */
+function multiple_email_confirm_page_resend_submit($form, &$form_state) {
+  $email = $form_state['values']['email'];
+  $account = $form_state['values']['account'];
+  // Send a confirmation email if one has not been sent within the specified days.
+  $email->confirm_code = multiple_email_code();
+  db_query("UPDATE {multiple_email} SET confirm_code = '%s', time_code_generated = %d, attempts = 0 WHERE eid = %d", $email->confirm_code, time(), $email->eid);
+  multiple_email_send_confirmation($account, $email);
+}
Index: multiple_email_manage.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multiple_email/Attic/multiple_email_manage.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 multiple_email_manage.inc
--- multiple_email_manage.inc	11 Jan 2011 04:35:44 -0000	1.1.2.3
+++ multiple_email_manage.inc	13 Jan 2011 05:08:14 -0000
@@ -30,7 +30,8 @@ function multiple_email_manage(&$form_st
     if (user_access('administer users')) {
       $form['addresses'][$email->eid]['confirm'] = array(
         '#type' => 'checkbox',
-        '#title' => t('Confirm this email'),
+        '#title' => t('Confirm this email (!resend)',
+          array('!resend' => l(t('resend'), 'user/'. $account->uid .'/edit/email-addresses/confirm/'. $email->eid .'/resend'))),
         '#default_value' => $email->confirmed,
         // Does this make sense?
 //        '#disabled' => $email->primary_address,
