Index: messaging_sendto.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/messaging_sendto/messaging_sendto.module,v
retrieving revision 1.1
diff -u -p -r1.1 messaging_sendto.module
--- messaging_sendto.module	18 Dec 2008 18:46:41 -0000	1.1
+++ messaging_sendto.module	14 May 2009 02:02:55 -0000
@@ -365,17 +365,22 @@ function messaging_sendto_autocomplete($
 
 function messaging_sendto_js() {
   // Load the form from the Form API cache.
-  if (!($cached_form = form_get_cache($_POST['form_build_id'], $cached_form_state))) {
+  $form_state = array('storage' => NULL, 'submitted' => FALSE);
+  $form_build_id = $_POST['form_build_id'];
+  $form = form_get_cache($form_build_id, $form_state);
+  if (!($form = form_get_cache($form_build_id, $form_state))) {
     form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
     $output = theme('status_messages');
     print drupal_to_js(array('status' => TRUE, 'data' => $output));
     exit();
   }
-
-  $form_state = array('values' => $_POST);
-
-  // Handle new uploads, and merge tmp files into node-files.
-  messaging_sendto_form_submit($cached_form, $form_state);
+  $args = $form['#parameters'];
+  $form_id = array_shift($args);
+  $form_state['post'] = $form['#post'] = $_POST;
+  $form['#programmed'] = $form['#redirect'] = FALSE;
+  // Process form, which calls submit handlers.
+  drupal_process_form($form_id, $form, $form_state);
+  // $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
   $output = theme('status_messages');
   print drupal_to_js(array('status' => TRUE, 'data' => $output));
   exit();
@@ -422,8 +427,8 @@ function _messaging_sendto_match($destin
     return array('email', $destination, $method);
   } 
   // May be a phone number
-  elseif (($method = _messaging_sendto_available('sms')) && user_access('forward content by sms') && sms_validate_number($destination)) {
-    return array('number', $number, $method);
+  elseif (($method = _messaging_sendto_available('sms')) && user_access('forward content by sms') && !sms_validate_number($destination)) {
+    return array('number', $destination, $method);
   }
   // May be nonsense
   else {
