From 73f8cabc6809128e21f47c0b1ab837988befe86e Mon Sep 17 00:00:00 2001
From: Matthew Radcliffe <mradcliffe@kosada.com>
Date: Sun, 13 Nov 2011 21:20:48 -0800
Subject: [PATCH] Fixes issues [#1227616] and [#1200584] with Views Bulk Operations 6.x-1.11 and higher.

---
 views_send.module |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/views_send.module b/views_send.module
index e7d8d3c..9c98542 100644
--- a/views_send.module
+++ b/views_send.module
@@ -225,6 +225,8 @@ function views_send_mail_action_form($context) {
  */
 function views_send_mail_action_validate($form, $form_state) {
   $values =& $form_state['values'];
+  $plugin = $form['#plugin'];
+  $form_id = $values['form_id'];
 
   // Check if sender's E-mail is a valid one.
   if (!valid_email_address($values['views_send_from_mail'])) {
@@ -240,10 +242,12 @@ function views_send_mail_action_validate($form, $form_state) {
      * action's form with node selection view" checkbox is checked. We are on
      * first submit and the $form_state['storage'] is not populated yet.
      */
-    if ($values['step'] == VIEWS_BULK_OPS_STEP_SINGLE) {
+    if ($values['step'] == VBO_STEP_SINGLE) {
       // Normalize selection.
-      _views_bulk_operations_adjust_selection($values['objects']['selection'], $values['objects']['select_all'], $values['exposed_input'], $values['arguments'], $form['#plugin']);
-      $records =& $values['objects']['selection'];
+      $form_state['storage']['selection'] = _views_bulk_operations_get_selection($plugin, $form_state, $form_id);
+      $form_state['storage']['selectall'] = $form_state['values']['objects']['selectall'];
+      $form_state['storage']['operation'] = $operation = $plugin->get_operation_info($form_state['values']['operation']);
+      $records =& $form_state['storage']['selection'];
     }
     /**
      * Common usage: "views_send_mail_action" isn't the only action configured
@@ -251,7 +255,7 @@ function views_send_mail_action_validate($form, $form_state) {
      * checked. $form_state['storage'] is populated and we will use it.
      */
     else {
-      $records =& $form_state['storage'][1]['objects']['selection'];
+      $records =& $form_state['storage']['selection'];
     }
 
     foreach ($records as $record) {
@@ -425,7 +429,7 @@ function views_send_form_alter($form, $form_state, $form_id) {
     );
 
     $recipients = array();
-    foreach ($form_state['storage'][1]['objects']['selection'] as $oid => $row) {
+    foreach ($form_state['storage']['selection'] as $oid => $row) {
       $email = $row->{$form_state["storage"]["operation_arguments"]["views_send_to_mail"]};
       $name = empty($form_state['storage']['operation_arguments']['views_send_to_name']) ? '' : $row->{$form_state["storage"]["operation_arguments"]["views_send_to_name"]};
       $recipients[] = check_plain(empty($name) ? $email : $name .' <'. $email .'>');
-- 
1.7.4.1

