/[drupal]/contributions/modules/mailhandler/mailhandler.module
ViewVC logotype

Diff of /contributions/modules/mailhandler/mailhandler.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.87.2.9, Fri May 2 17:32:18 2008 UTC revision 1.87.2.10, Sun Jul 6 20:07:09 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: mailhandler.module,v 1.87.2.8 2008/05/02 15:06:45 weitzman Exp $  // $Id: mailhandler.module,v 1.87.2.9 2008/05/02 17:32:18 weitzman Exp $
3    
4  /**  /**
5   * Retrieve all msgs from a given mailbox and process them.   * Retrieve all msgs from a given mailbox and process them.
# Line 151  function mailhandler_node_submit($node, Line 151  function mailhandler_node_submit($node,
151    list($fromaddress, $fromname) = mailhandler_get_fromaddress($header, $mailbox);    list($fromaddress, $fromname) = mailhandler_get_fromaddress($header, $mailbox);
152    
153    //dprint_r($node); //DEBUG    //dprint_r($node); //DEBUG
154    
155      // Drupal 5.x & 6.x don't support multiple validations: each node_validate()
156      // call will ADD error messages to previous ones, so if some validation error
157      // occours in one message it will be reported in all messages after it.
158      // Since there is no way to reset form errors, the only method to avoid this
159      // problem is working with $_SESSION['messages'], used by form_set_error().
160      // See http://drupal.org/node/271975 for more info.
161      // Warning: with this method, if the same error message is reported for 2+ different
162      // fields it will be detected only for the last one.
163    
164      if (!isset($_SESSION['messages'])) {
165        $_SESSION['messages'] = array();
166      }
167      $saved_errors = is_array($_SESSION['messages']['error']) ? $_SESSION['messages']['error'] : array();
168      $_SESSION['messages']['error'] = array();
169    node_validate($node);    node_validate($node);
170    $error = form_get_errors();    $error = array();
171      if (count($_SESSION['messages']['error'])) {
172        $allerrors = form_get_errors();
173        foreach ($_SESSION['messages']['error'] as $message) {
174          $keys = array_keys($allerrors, $message);
175          if (!$keys || !count($keys)) {
176            // Not a validation error (but an error, i'll print it)
177            $saved_errors[] = $message;
178          } else {
179            // This is a validation error, i take the last field with it (previous fields
180            // should be about previous validations)
181            $error[$keys[count($keys) - 1]] = $message;
182          }
183        }
184      }
185      $_SESSION['messages']['error'] = $saved_errors;
186    
187    if (!$error) {    if (!$error) {
188      // Prepare the node for save and allow modules make changes      // Prepare the node for save and allow modules make changes
189      $node = node_submit($node);      $node = node_submit($node);

Legend:
Removed from v.1.87.2.9  
changed lines
  Added in v.1.87.2.10

  ViewVC Help
Powered by ViewVC 1.1.2