diff --git a/salesforce_webforms.api.php b/salesforce_webforms.api.php index 9a6fc06..f78a173 100644 --- a/salesforce_webforms.api.php +++ b/salesforce_webforms.api.php @@ -199,16 +199,9 @@ function hook_salesforce_webforms_push_params_alter(&$fields, $context) { * Each filter is an array with the following keys: * - label -- The human-readable label for the filter. * - callback -- The name of the function which implements this filter. The - * function should accept a parameter which will be the - * unfiltered data as a string, and, optionally, a second - * parameter, the node this field belongs to, - * and should return the filtered string. - * The filter can suppress the sending of the data to Salesforce - * by setting - * $node->webform['salesforce_settings']['suppress_save'] - * to TRUE, and can provide status messages by adding to the - * $node->webform['salesforce_settings']['messages'] - * array. + * function should accept a single parameter which will be the + * unfiltered data as a string, and should return the filtered + * string. * - field types -- An array of Salesforce field for which this filter is valid. * If not defined, then the filter will be available for all * data types. diff --git a/salesforce_webforms.filters.inc b/salesforce_webforms.filters.inc index 5a9192f..b5e25a9 100644 --- a/salesforce_webforms.filters.inc +++ b/salesforce_webforms.filters.inc @@ -14,25 +14,10 @@ * @return string * The filtered value in the form YYYY-MM-DD */ -function salesforce_webforms_date_filter($date, $node) { - // Return NULL if we have no source data - if ($date == NULL || $date == '' || ctype_space($date)) { - return NULL; - } - +function salesforce_webforms_date_filter($date) { // Get the default date format. $format = webform_date_format(); $date = date_parse_from_format($format, $date); - - // Did we get an error in parsing? - if ($date['error_count'] > 0) { - $node->webform['salesforce_settings']['suppress_save'] = TRUE; - $node->webform['salesforce_settings']['messages'][] = array( - 'message' => t('Invalid date'), - 'type' => 'error', - ); - return NULL; - } return sprintf('%04.4d-%02.2d-%02.2d', $date['year'], $date['month'], $date['day']); } @@ -45,24 +30,9 @@ function salesforce_webforms_date_filter($date, $node) { * @return string * The filtered value in the form YYYY-MM-DDTHH:MM:SSZ */ -function salesforce_webforms_datetime_filter($datetime, $node) { - // Return NULL if we have no source data - if ($datetime == NULL || $datetime == '' || ctype_space($datetime)) { - return NULL; - } - +function salesforce_webforms_datetime_filter($datetime) { $format = webform_date_format(); $date = date_parse_from_format($format, $datetime); - - // Did we get an error in parsing? - if ($date['error_count'] > 0) { - $node->webform['salesforce_settings']['suppress_save'] = TRUE; - $node->webform['salesforce_settings']['messages'] += array( - 'message' => t('Invalid date/time'), - 'type' => 'error', - ); - return NULL; - } return sprintf('%04.4d-%02.2d-%02.2dT%02.2d:%02.2d:%02.2dZ', $date['year'], $date['month'], $date['day'], $date['hour'], $date['minute'], $date['second']); diff --git a/salesforce_webforms.maps.inc b/salesforce_webforms.maps.inc index 3c7d0c2..6e27c42 100644 --- a/salesforce_webforms.maps.inc +++ b/salesforce_webforms.maps.inc @@ -14,17 +14,12 @@ * @returns array * An associative array of setting names and values * - suppress_errors: (int) Flag indicating if errors should be suppressed. - * - nid: (int) Node Id - * - suppress_save: (flag) Indicator from a filter that the data is not ok. - * - messages: (array) messages to present to the end user. */ function salesforce_webforms_settings_get($nid) { // Set default values. $return = array( 'suppress_errors' => FALSE, 'nid' => $nid, - 'suppress_save' => FALSE, - 'messages' => array(), ); // Pull any settings found in the database. @@ -192,8 +187,6 @@ function salesforce_webforms_get_nodes_maps($nodes) { 'settingid' => $setting->settingid, 'nid' => $setting->nid, 'suppress_errors' => $setting->suppress_errors, - 'messages' => array(), - 'suppress_save' => FALSE, ); } diff --git a/salesforce_webforms.module b/salesforce_webforms.module index 6e29758..78f92e3 100644 --- a/salesforce_webforms.module +++ b/salesforce_webforms.module @@ -622,7 +622,7 @@ function salesforce_webforms_webform_submission_insert($node, $sub, $update = FA // Do we have any filters to apply? if (isset($field['filter'])) { - $filtered_source = salesforce_webforms_filter_invoke($field['filter'], $filtered_source, $node); + $filtered_source = salesforce_webforms_filter_invoke($field['filter'], $filtered_source); } if ($key) { @@ -638,20 +638,6 @@ function salesforce_webforms_webform_submission_insert($node, $sub, $update = FA continue; } - if (!$suppress_errors) { - foreach($node->webform['salesforce_settings']['messages'] as $message) { - drupal_set_message($message['message'], $message['type']); - } - } - - // Clear out any processed messages. - $node->webform['salesforce_settings']['messages'] = array(); - - // Did any filter flag to suppress saving to Salesforce? - if ($node->webform['salesforce_settings']['suppress_save']) { - continue; - } - // See if we are always creating new, or trying to update existing. $target_id = isset($existing_keys[$mapname]) ? $existing_keys[$mapname] : FALSE; if (!$target_id && count($keyfields) > 0) { @@ -1064,13 +1050,11 @@ function salesforce_webforms_filter_include($filter_type) { * The machine name of the filter. * @param string $value * The source value, after all tokens have been replaced. - * @param array $node - * The node that owns this field * * @return string|array * The filtered value, as returned by the callback function. */ -function salesforce_webforms_filter_invoke($filter, $value, $node) { +function salesforce_webforms_filter_invoke($filter, $value) { // Initialize the return value to be the same as the source. $return = $value; @@ -1084,7 +1068,7 @@ function salesforce_webforms_filter_invoke($filter, $value, $node) { // Make sure the function's definition has been included. salesforce_webforms_filter_include($filter); if (function_exists($callback)) { - $return = $callback($value, $node); + $return = $callback($value); } }