Index: includes/webform.submissions.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.submissions.inc,v retrieving revision 1.22 diff -u -r1.22 webform.submissions.inc --- includes/webform.submissions.inc 16 Mar 2010 00:11:58 -0000 1.22 +++ includes/webform.submissions.inc 26 Mar 2010 00:36:08 -0000 @@ -164,9 +164,18 @@ function webform_submission_delete_form($form, $form_state, $node, $submission) { webform_set_breadcrumb($node, $submission); - $form = array(); - $form['node'] = array('#type' => 'value', '#value' => $node); - $form['submission'] = array('#type' => 'value', '#value' => $submission); + // Keep the NID and SID in the same location as the webform_client_form(). + // This helps mollom identify the same fields when deleting a submission. + $form['#tree'] = TRUE; + $form['details']['nid'] = array( + '#type' => 'value', + '#value' => $node->nid, + ); + $form['details']['sid'] = array( + '#type' => 'value', + '#value' => $submission->sid, + ); + $question = t('Are you sure you want to delete this submission?'); if (isset($_GET['destination'])) { @@ -183,10 +192,12 @@ } function webform_submission_delete_form_submit($form, &$form_state) { - webform_submission_delete($form_state['values']['node'], $form_state['values']['submission']); + $node = node_load($form_state['values']['details']['nid']); + $submission = webform_get_submission($form_state['values']['details']['nid'], $form_state['values']['details']['sid']); + webform_submission_delete($node, $submission); drupal_set_message(t('Submission deleted.')); - $form_state['redirect'] = 'node/' . $form_state['values']['node']->nid . '/webform-results'; + $form_state['redirect'] = 'node/' . $node->nid . '/webform-results'; } /** Index: includes/webform.components.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.components.inc,v retrieving revision 1.35 diff -u -r1.35 webform.components.inc --- includes/webform.components.inc 25 Mar 2010 23:46:29 -0000 1.35 +++ includes/webform.components.inc 26 Mar 2010 00:36:08 -0000 @@ -781,6 +781,7 @@ 'email_name' => FALSE, 'required' => TRUE, 'conditional' => TRUE, + 'spam_analysis' => FALSE, ); return isset($components[$type]['features'][$feature]) ? $components[$type]['features'][$feature] : $defaults[$feature]; } Index: webform.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v retrieving revision 1.206 diff -u -r1.206 webform.module --- webform.module 25 Mar 2010 02:07:25 -0000 1.206 +++ webform.module 26 Mar 2010 00:36:08 -0000 @@ -652,6 +652,7 @@ 'file' => 'components/email.inc', 'features' => array( 'email_address' => TRUE, + 'spam_analysis' => TRUE, ), ), 'fieldset' => array( @@ -722,6 +723,9 @@ 'label' => t('Textarea'), 'description' => t('A large text area that allows for multiple lines of input.'), 'file' => 'components/textarea.inc', + 'features' => array( + 'spam_analysis' => TRUE, + ), ), 'textfield' => array( 'label' => t('Textfield'), @@ -729,6 +733,7 @@ 'file' => 'components/textfield.inc', 'features' => array( 'email_name' => TRUE, + 'spam_analysis' => TRUE, ), ), 'time' => array( @@ -1344,6 +1349,10 @@ '#type' => 'hidden', '#value' => isset($submission->sid) ? $submission->sid : '', ); + $form['details']['uid'] = array( + '#type' => 'value', + '#value' => $user->uid, + ); $form['details']['finished'] = array( '#type' => 'hidden', '#value' => isset($submission->draft) ? !$submission->draft : 0, @@ -2826,3 +2835,92 @@ 'path' => drupal_get_path('module', 'webform') .'/views', ); } + +/** + * Implements hook_mollom_form_list(). + */ +function webform_mollom_form_list() { + $forms = array(); + $webform_types = webform_variable_get('webform_node_types'); + if (empty($webform_types)) { + return $forms; + } + + $result = db_select('node', 'n') + ->fields('n', array('nid', 'title')) + ->condition('n.type', $webform_types, 'IN') + ->execute(); + + foreach ($result as $node) { + $form_id = 'webform_client_form_' . $node->nid; + $forms[$form_id] = array( + 'title' => t('@name form', array('@name' => $node->title)), + 'entity' => 'webform', + 'delete form' => 'webform_submission_delete_form', + ); + } + return $forms; +} + +/** + * Implements hook_mollom_form_info(). + */ +function webform_mollom_form_info($form_id) { + module_load_include('inc', 'webform', 'includes/webform.components'); + + $nid = drupal_substr($form_id, 20); + $node = node_load($nid); + $form_info = array( + 'title' => t('@name form', array('@name' => $node->title)), + 'mode' => MOLLOM_MODE_ANALYSIS, + 'bypass access' => array('edit all webform submissions', 'edit any webform content'), + 'entity' => 'webform', + 'elements' => array(), + 'mapping' => array( + 'post_id' => 'details][sid', + 'author_id' => 'details][uid', + ), + ); + // Add components as elements. + // These components can be enabled for textual analysis (when not using a + // CAPTCHA-only protection) in Mollom's form configuration. + foreach ($node->webform['components'] as $cid => $component) { + if (webform_component_feature($component['type'], 'spam_analysis')) { + $parents = implode('][', webform_component_parent_keys($node, $component)); + $form_info['elements']['submitted][' . $parents] = check_plain(t($component['name'])); + } + } + // Assign field mappings based on webform configuration. + // Since multiple emails can be configured, we iterate over all and take + // over the assigned component for the field mapping in any email, unless + // we already assigned one. We are not interested in administratively + // configured static strings, only user-submitted values. + foreach ($node->webform['emails'] as $email) { + // Subject (post_title). + if (!isset($form_info['mapping']['post_title'])) { + $cid = $email['subject']; + if (is_numeric($cid)) { + $parents = implode('][', webform_component_parent_keys($node, $node->webform['components'][$cid])); + $form_info['mapping']['post_title'] = 'submitted][' . $parents; + } + } + // From name (author_name). + if (!isset($form_info['mapping']['author_name'])) { + $cid = $email['from_name']; + if (is_numeric($cid)) { + $parents = implode('][', webform_component_parent_keys($node, $node->webform['components'][$cid])); + $form_info['mapping']['author_name'] = 'submitted][' . $parents; + } + } + // From address (author_mail). + if (!isset($form_info['mapping']['author_mail'])) { + $cid = $email['from_address']; + if (is_numeric($cid)) { + $parents = implode('][', webform_component_parent_keys($node, $node->webform['components'][$cid])); + $form_info['mapping']['author_mail'] = 'submitted][' . $parents; + } + } + } + + return $form_info; +}