Index: webform.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v retrieving revision 1.196.2.2 diff -u -p -r1.196.2.2 webform.module --- webform.module 8 Mar 2010 01:04:08 -0000 1.196.2.2 +++ webform.module 10 Mar 2010 16:48:39 -0000 @@ -1295,6 +1295,10 @@ function webform_client_form(&$form_stat '#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, @@ -2677,6 +2681,19 @@ function webform_component_invoke($type, } /** + * Find a components parents within a node. + */ +function webform_component_parent_keys($node, $component) { + $parents = array($component['form_key']); + $pid = $component['pid']; + while ($pid) { + $parents[] = $node->webform['components'][$pid]['form_key']; + $pid = $node->webform['components'][$pid]['pid']; + } + return array_reverse($parents); +} + +/** * Disable the Drupal page cache. */ function webform_disable_page_cache() { @@ -2734,3 +2751,86 @@ function webform_views_api() { '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; + } + $placeholders = db_placeholders($webform_types, 'varchar'); + $result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type IN ($placeholders)", 'n', 'nid', $webform_types), $webform_types); + while ($node = db_fetch_object($result)) { + $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) { + $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 (in_array($component['type'], array('textfield', 'email', 'textarea'))) { + $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; +} Index: includes/webform.components.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.components.inc,v retrieving revision 1.25.2.3 diff -u -p -r1.25.2.3 webform.components.inc --- includes/webform.components.inc 10 Mar 2010 03:53:10 -0000 1.25.2.3 +++ includes/webform.components.inc 10 Mar 2010 16:37:11 -0000 @@ -837,19 +837,6 @@ function theme_webform_component_select( } /** - * Find a components parents within a node. - */ -function webform_component_parent_keys($node, $component) { - $parents = array($component['form_key']); - $pid = $component['pid']; - while ($pid) { - $parents[] = $node->webform['components'][$pid]['form_key']; - $pid = $node->webform['components'][$pid]['pid']; - } - return array_reverse($parents); -} - -/** * Populate a component with the defaults for that type. */ function webform_component_defaults(&$component) { Index: includes/webform.submissions.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.submissions.inc,v retrieving revision 1.18.2.3 diff -u -p -r1.18.2.3 webform.submissions.inc --- includes/webform.submissions.inc 10 Mar 2010 03:53:10 -0000 1.18.2.3 +++ includes/webform.submissions.inc 10 Mar 2010 16:39:47 -0000 @@ -133,7 +133,10 @@ function webform_submission_delete($node function webform_submission_delete_form($form_state, $node, $submission) { webform_set_breadcrumb($node, $submission); - $form = array(); + // Always provide the entity id in the same key as in the entity edit form. + $form['#tree'] = TRUE; + $form['details']['sid'] = array('#type' => 'value', '#value' => $submission->sid); + $form['node'] = array('#type' => 'value', '#value' => $node); $form['submission'] = array('#type' => 'value', '#value' => $submission); $question = t('Are you sure you want to delete this submission?');