Index: webform.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v retrieving revision 1.197 diff -u -r1.197 webform.module --- webform.module 3 Mar 2010 02:51:37 -0000 1.197 +++ webform.module 8 Mar 2010 00:55:53 -0000 @@ -18,7 +18,7 @@ function webform_help($section = 'admin/help#webform', $arg = NULL) { $output = ''; switch ($section) { - case 'admin/settings/webform': + case 'admin/config/content/webform': $type_list = webform_admin_type_list(); $output = t('Webform enables nodes to have attached forms and questionnaires.'); if ($type_list) { @@ -37,10 +37,10 @@ $types = webform_admin_type_list(); if (empty($types)) { $types = t('Webform-enabled piece of content'); - $types_message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the Webform settings page and enable Webform on at least one content type.', array('!url' => url('admin/settings/webform'))); + $types_message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the Webform settings page and enable Webform on at least one content type.', array('!url' => url('admin/config/content/webform'))); } else { - $types_message = t('Optional: Enable Webform on multiple types by visiting the Webform settings page.', array('!url' => array('admin/settings/webform'))); + $types_message = t('Optional: Enable Webform on multiple types by visiting the Webform settings page.', array('!url' => array('admin/config/content/webform'))); } $output = t("

This module lets you create forms or questionnaires and define their content. Submissions from these forms are stored in the database and optionally also sent by e-mail to a predefined address.

Here is how to create one:

@@ -89,7 +89,7 @@ ); // Admin Settings. - $items['admin/settings/webform'] = array( + $items['admin/config/content/webform'] = array( 'title' => 'Webform settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('webform_admin_settings'), @@ -471,15 +471,31 @@ /** * Implementation of hook_perm(). */ -function webform_perm() { +function webform_permission() { return array( - 'access all webform results', - 'access own webform results', - 'edit all webform submissions', - 'delete all webform submissions', - 'access own webform submissions', - 'edit own webform submissions', - 'delete own webform submissions', + 'access all webform results' => array( + 'title' => t('Access all webform results'), + 'description' => t('Grants access to the "Results" tab on all webform nodes. Generally an administrative permission.'), + ), + 'access own webform results' => array( + 'title' => t('Access own webform results'), + 'description' => t('Grants access to the "Results" tab on webform nodes to the author.'), + ), + 'edit all webform submissions' => array( + 'title' => t('Edit all webform submissions'), + ), + 'delete all webform submissions' => array( + 'title' => t('Delete all webform submissions'), + ), + 'access own webform submissions' => array( + 'title' => t('Access own webform submissions'), + ), + 'edit own webform submissions' => array( + 'title' => t('Edit own webform submissions'), + ), + 'delete own webform submissions' => array( + 'title' => t('Delete own webform submissions'), + ), ); } @@ -490,124 +506,124 @@ $theme = array( // webform.module. 'webform_view' => array( - 'arguments' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'form' => NULL, 'enabled' => NULL), + 'render element' => 'webform', ), 'webform_view_messages' => array( - 'arguments' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL), + 'variables' => array('node' => NULL, 'teaser' => NULL, 'page' => NULL, 'submission_count' => NULL, 'limit_exceeded' => NULL, 'allowed_roles' => NULL), ), 'webform_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'template' => 'templates/webform-form', 'pattern' => 'webform_form_[0-9]+', ), 'webform_advanced_submit_limit_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.pages.inc', ), 'webform_confirmation' => array( - 'arguments' => array('node' => NULL, 'sid' => NULL), + 'variables' => array('node' => NULL, 'sid' => NULL), 'template' => 'templates/webform-confirmation', 'pattern' => 'webform_confirmation_[0-9]+', ), 'webform_element' => array( - 'arguments' => array('element' => NULL, 'value' => NULL), + 'render element' => 'element', ), 'webform_element_text' => array( - 'arguments' => array('element' => NULL, 'value' => NULL), + 'render element' => 'element', ), 'webform_mail_message' => array( - 'arguments' => array('node' => NULL, 'submission' => NULL, 'cid' => NULL), + 'variables' => array('node' => NULL, 'submission' => NULL, 'cid' => NULL), 'template' => 'templates/webform-mail', 'pattern' => 'webform_mail(_[0-9]+)?', ), 'webform_mail_headers' => array( - 'arguments' => array('node' => NULL, 'submission' => NULL, 'cid' => NULL), + 'variables' => array('node' => NULL, 'submission' => NULL, 'cid' => NULL), 'pattern' => 'webform_mail_headers_[0-9]+', ), 'webform_token_help' => array( - 'arguments' => array(), + 'variables' => array(), ), // webform.admin.inc. 'webform_admin_settings' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.admin.inc', ), 'webform_admin_content' => array( - 'arguments' => array('nodes' => NULL), + 'variables' => array('nodes' => NULL), 'file' => 'includes/webform.admin.inc', ), // webform.emails.inc. 'webform_emails_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.emails.inc', ), 'webform_email_add_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.emails.inc', ), 'webform_email_edit_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.emails.inc', ), // webform.components.inc. 'webform_components_page' => array( - 'arguments' => array('node' => NULL, 'mode' => NULL, 'form' => NULL), + 'variables' => array('node' => NULL, 'mode' => NULL, 'form' => NULL), 'file' => 'includes/webform.components.inc', ), 'webform_components_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.components.inc', ), 'webform_component_select' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', 'file' => 'includes/webform.components.inc', ), // webform.report.inc. 'webform_results_per_page' => array( - 'arguments' => array('total_count' => NULL, 'pager_count' => NULL), + 'variables' => array('total_count' => NULL, 'pager_count' => NULL), 'file' => 'includes/webform.report.inc', ), 'webform_results_submissions_header' => array( - 'arguments' => array('node' => NULL), + 'variables' => array('node' => NULL), 'file' => 'includes/webform.report.inc', ), 'webform_results_submissions' => array( - 'arguments' => array('node' => NULL, 'submissions' => NULL, 'total_count' => NULL, 'pager_count' => NULL), + 'variables' => array('node' => NULL, 'submissions' => NULL, 'total_count' => 0, 'pager_count' => 0), 'file' => 'includes/webform.report.inc', ), 'webform_results_table_header' => array( - 'arguments' => array('node' => NULL), + 'variables' => array('node' => NULL), 'file' => 'includes/webform.report.inc', ), 'webform_results_table' => array( - 'arguments' => array('node' => NULL, 'components' => NULL, 'submissions' => NULL, 'node' => NULL, 'total_count' => NULL, 'pager_count' => NULL), + 'variables' => array('node' => NULL, 'components' => NULL, 'submissions' => NULL, 'node' => NULL, 'total_count' => NULL, 'pager_count' => NULL), 'file' => 'includes/webform.report.inc', ), 'webform_results_download_form' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', 'file' => 'includes/webform.report.inc', ), 'webform_results_download_select_format' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', 'file' => 'includes/webform.report.inc', ), 'webform_results_analysis' => array( - 'arguments' => array('node' => NULL, 'data' => NULL, 'sids' => array(), 'component' => NULL), + 'variables' => array('node' => NULL, 'data' => NULL, 'sids' => array(), 'component' => NULL), 'file' => 'includes/webform.report.inc', ), // webform.submissions.inc 'webform_submission_page' => array( - 'arguments' => array('node' => NULL, 'submission' => NULL, 'submission_content' => NULL, 'submission_navigation' => NULL, 'submission_information' => NULL), + 'variables' => array('node' => NULL, 'submission' => NULL, 'submission_content' => NULL, 'submission_navigation' => NULL, 'submission_information' => NULL), 'template' => 'templates/webform-submission-page', 'file' => 'includes/webform.submissions.inc', ), 'webform_submission_information' => array( - 'arguments' => array('node' => NULL, 'submission' => NULL), + 'variables' => array('node' => NULL, 'submission' => NULL), 'template' => 'templates/webform-submission-information', 'file' => 'includes/webform.submissions.inc', ), 'webform_submission_navigation' => array( - 'arguments' => array('node' => NULL, 'submission' => NULL, 'mode' => NULL), + 'variables' => array('node' => NULL, 'submission' => NULL, 'mode' => NULL), 'template' => 'templates/webform-submission-navigation', 'file' => 'includes/webform.submissions.inc', ), @@ -777,6 +793,8 @@ /** * Implementation of hook_node_type(). + * + * Not a real hook in Drupal 7. Re-used for consistency with the D6 version. */ function webform_node_type($op, $info) { $webform_types = webform_variable_get('webform_node_types'); @@ -794,31 +812,17 @@ } /** - * Implementation of hook_nodeapi(). + * Implementation of hook_node_type_update(). */ -function webform_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { - if (!in_array($node->type, webform_variable_get('webform_node_types'))) { - return; - } +function webform_node_type_update($info) { + webform_node_type('update', $info); +} - switch ($op) { - case 'insert': - webform_node_insert($node); - break; - case 'update': - webform_node_update($node); - break; - case 'delete': - webform_node_delete($node); - break; - case 'prepare': - webform_node_prepare($node); - break; - case 'load': - return webform_node_load($node); - case 'view': - return webform_node_view($node, $teaser, $page); - } +/** + * Implementation of hook_node_type_delete(). + */ +function webform_node_type_delete($info) { + webform_node_type('delete', $info); } /** @@ -832,7 +836,22 @@ module_load_include('inc', 'webform', 'includes/webform.components'); // Insert the webform. - db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, redirect_url, teaser, allow_draft, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['redirect_url'], $node->webform['teaser'], $node->webform['allow_draft'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['additional_validate'], $node->webform['additional_submit']); + db_insert('webform') + ->fields(array( + 'nid' => $node->nid, + 'confirmation' => $node->webform['confirmation'], + 'confirmation_format' => $node->webform['confirmation_format'], + 'redirect_url' => $node->webform['redirect_url'], + 'teaser' => $node->webform['teaser'], + 'allow_draft' => $node->webform['allow_draft'], + 'submit_notice' => $node->webform['submit_notice'], + 'submit_text' => $node->webform['submit_text'], + 'submit_limit' => $node->webform['submit_limit'], + 'submit_interval' => $node->webform['submit_interval'], + 'additional_validate' => $node->webform['additional_validate'], + 'additional_submit' => $node->webform['additional_submit'], + )) + ->execute(); // Insert the components into the database. Used with clone.module. if (isset($node->webform['components']) && !empty($node->webform['components'])) { @@ -844,7 +863,12 @@ // Set the per-role submission access control. foreach (array_filter($node->webform['roles']) as $rid) { - db_query('INSERT INTO {webform_roles} (nid, rid) VALUES (%d, %d)', $node->nid, $rid); + db_insert('webform_roles') + ->fields(array( + 'nid' => $node->nid, + 'rid' => $rid + )) + ->execute(); } } @@ -857,9 +881,9 @@ } // Update the webform by deleting existing data and replacing with the new. - db_query('DELETE FROM {webform} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_component} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_roles} WHERE nid = %d', $node->nid); + db_delete('webform')->condition('nid', $node->nid)->execute(); + db_delete('webform_component')->condition('nid', $node->nid)->execute(); + db_delete('webform_roles')->condition('nid', $node->nid)->execute(); webform_node_insert($node); } @@ -878,96 +902,108 @@ } // Remove any trace of webform data from the database. - db_query('DELETE FROM {webform} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_component} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_roles} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_submissions} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {webform_submitted_data} WHERE nid = %d', $node->nid); + db_delete('webform')->condition('nid', $node->nid)->execute(); + db_delete('webform_component')->condition('nid', $node->nid)->execute(); + db_delete('webform_roles')->condition('nid', $node->nid)->execute(); + db_delete('webform_submissions')->condition('nid', $node->nid)->execute(); + db_delete('webform_submitted_data')->condition('nid', $node->nid)->execute(); } /** * Implementation of hook_node_prepare(). */ -function webform_node_prepare(&$node) { - if (!isset($node->webform)) { - $additions = webform_node_load($node); - $node->webform = $additions['webform']; +function webform_node_prepare($node) { + $webform_types = webform_variable_get('webform_node_types'); + if (in_array($node->type, $webform_types) && !isset($node->webform)) { + $nodes = array($node->nid => $node); + $types = array($node->type); + webform_node_load($nodes, $types); } } /** * Implementation of hook_node_load(). */ -function webform_node_load($node) { +function webform_node_load(&$nodes, $types) { module_load_include('inc', 'webform', 'includes/webform.components'); - $additions = array(); - if (isset($node->nid) && ($webform = db_fetch_array(db_query('SELECT * FROM {webform} WHERE nid = %d', $node->nid)))) { - $additions['webform'] = $webform; - - $additions['webform']['roles'] = array(); - $result = db_query('SELECT rid FROM {webform_roles} WHERE nid = %d', $node->nid); - while ($role = db_fetch_object($result)) { - $additions['webform']['roles'][] = $role->rid; - } - - $additions['webform']['emails'] = array(); - $result = db_query('SELECT * FROM {webform_emails} WHERE nid = %d', $node->nid); - while ($email = db_fetch_array($result)) { - $additions['webform']['emails'][$email['eid']] = $email; - $additions['webform']['emails'][$email['eid']]['excluded_components'] = array_filter(explode(',', $email['excluded_components'])); - } - } - else { - $additions['webform'] = array( - 'confirmation' => '', - 'confirmation_format' => FILTER_FORMAT_DEFAULT, - 'redirect_url' => '', - 'teaser' => 0, - 'allow_draft' => 0, - 'submit_notice' => 0, - 'submit_text' => '', - 'submit_limit' => -1, - 'submit_interval' => -1, - 'additional_validate' => '', - 'additional_submit' => '', - 'roles' => array(1, 2), - 'emails' => array(), - ); + // Quick check to see if we need to do anything at all for these nodes. + $webform_types = webform_variable_get('webform_node_types'); + if (count(array_intersect($types, $webform_types)) == 0) { + return; } - $additions['webform']['components'] = array(); - - // If we don't have a NID yet, no point in doing additional queries. - if (!isset($node->nid)) { - return $additions; - } - - $result = db_query('SELECT * FROM {webform_component} WHERE nid = %d ORDER BY weight, name', $node->nid); - while ($c = db_fetch_array($result)) { - $component =& $additions['webform']['components'][$c['cid']]; - $component['nid'] = $node->nid; - $component['cid'] = $c['cid']; - $component['form_key'] = $c['form_key'] ? $c['form_key'] : $c['cid']; - $component['name'] = t($c['name']); - $component['type'] = $c['type']; - $component['value'] = $c['value']; - $component['extra'] = unserialize($c['extra']); - $component['mandatory'] = $c['mandatory']; - $component['pid'] = $c['pid']; - $component['weight'] = $c['weight']; - - webform_component_defaults($component); + // Load defaults for all nodes that are webforms. + foreach ($nodes as $nid => $node) { + if (in_array($node->type, $webform_types)) { + $nodes[$nid]->webform = array( + 'confirmation' => '', + 'confirmation_format' => filter_default_format(), + 'redirect_url' => '', + 'teaser' => 0, + 'allow_draft' => 0, + 'submit_notice' => 0, + 'submit_text' => '', + 'submit_limit' => -1, + 'submit_interval' => -1, + 'additional_validate' => '', + 'additional_submit' => '', + 'roles' => array(1, 2), + 'emails' => array(), + ); + } } - // Organize the components into a fieldset-based order. - if (!empty($additions['webform']['components'])) { - $component_tree = array(); - $page_count = 1; - _webform_components_tree_build($additions['webform']['components'], $component_tree, 0, $page_count); - $additions['webform']['components'] = _webform_components_tree_flatten($component_tree['children']); + // Select all webforms that match these node IDs. + $result = db_select('webform') + ->fields('webform') + ->condition('nid', array_keys($nodes), 'IN') + ->execute() + ->fetchAllAssoc('nid', PDO::FETCH_ASSOC); + + foreach ($result as $nid => $webform) { + // Load the basic information for each node. + $nodes[$nid]->webform = $webform; + $nodes[$nid]->webform['roles'] = db_select('webform_roles') + ->fields('webform_roles', array('rid')) + ->condition('nid', $nid) + ->execute() + ->fetchCol(); + $nodes[$nid]->webform['emails'] = db_select('webform_emails') + ->fields('webform_emails') + ->condition('nid', $nid) + ->execute() + ->fetchAllAssoc('eid', PDO::FETCH_ASSOC); + + // Unserialize the exclude component list for e-mails. + foreach ($nodes[$nid]->webform['emails'] as $eid => $email) { + $nodes[$nid]->webform['emails'][$eid]['excluded_components'] = array_filter(explode(',', $email['excluded_components'])); + } + + // Load components for each node. + $nodes[$nid]->webform['components'] = db_select('webform_component') + ->fields('webform_component') + ->condition('nid', $nid) + ->orderBy('weight') + ->orderBy('name') + ->execute() + ->fetchAllAssoc('cid', PDO::FETCH_ASSOC); + + // Do a little cleanup on each component. + foreach ($nodes[$nid]->webform['components'] as $cid => $component) { + $nodes[$nid]->webform['components'][$cid]['nid'] = $nid; + $nodes[$nid]->webform['components'][$cid]['extra'] = unserialize($component['extra']); + webform_component_defaults($nodes[$nid]->webform['components'][$cid]); + } + + // Organize the components into a fieldset-based order. + if (!empty($nodes[$nid]->webform['components'])) { + $component_tree = array(); + $page_count = 1; + _webform_components_tree_build($nodes[$nid]->webform['components'], $component_tree, 0, $page_count); + $nodes[$nid]->webform['components'] = _webform_components_tree_flatten($component_tree['children']); + } } - return $additions; } /** @@ -1022,8 +1058,13 @@ /** * Implementation of hook_node_view(). */ -function webform_node_view(&$node, $teaser, $page) { +function webform_node_view(&$node, $view_mode) { global $user; + + // Set teaser and page variables a la Drupal 6. + $teaser = $view_mode == 'teaser'; + $page = arg(0) == 'node' && arg(1) == $node->nid; + // If a teaser or a new node (during preview), do not display the form. if (($teaser && !$node->webform['teaser']) || empty($node->nid)) { return; @@ -1087,23 +1128,27 @@ // Render the form and generate the output. $form = drupal_get_form('webform_client_form_' . $node->nid, $node, $submission, $is_draft); - $output = theme('webform_view', $node, $teaser, $page, $form, $enabled); // Remove the surrounding
tag if this is a preview. - if ($node->build_mode == NODE_BUILD_PREVIEW) { - $output = preg_replace('/<\/?form[^>]*>/', '', $output); + if (!empty($node->in_preview)) { + $form['#type'] = 'markup'; } // Print out messages for the webform. - if ($node->build_mode != NODE_BUILD_PREVIEW && !$logging_in) { - theme('webform_view_messages', $node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles); + if (!empty($node->in_preview) && !$logging_in) { + theme('webform_view_messages', array('node' => $node, 'teaser' => $teaser, 'page' => $page, 'submission_count' => $submission_count, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => $allowed_roles)); } // Add the output to the node. - $node = node_prepare($node, $teaser); - if (isset($output)) { - $node->content['webform'] = array('#value' => $output, '#weight' => 10); - } + $node->content['webform'] = array( + '#theme' => 'webform_view', + '#node' => $node, + '#teaser' => $teaser, + '#page' => $page, + '#form' => $form, + '#enabled' => $enabled, + '#weight' => 10, + ); } /** @@ -1120,10 +1165,10 @@ * @param $enabled * If the form allowed to be completed by the current user. */ -function theme_webform_view($node, $teaser, $page, $form, $enabled) { +function theme_webform_view($variables) { // Only show the form if this user is allowed access. - if ($enabled) { - return $form; + if ($variables['webform']['#enabled']) { + return drupal_render($variables['webform']['#form']); } } @@ -1144,9 +1189,16 @@ * @param $allowed_roles * A list of user roles that are allowed to submit this webform. */ -function theme_webform_view_messages($node, $teaser, $page, $submission_count, $limit_exceeded, $allowed_roles) { +function theme_webform_view_messages($variables) { global $user; + $node = $variables['node']; + $teaser = $variables['teaser']; + $page = $variables['page']; + $submission_count = $variables['submission_count']; + $limit_exceeded = $variables['limit_exceeded']; + $allowed_roles = $variables['allowed_roles']; + $type = 'notice'; $cached = $user->uid == 0 && variable_get('cache', CACHE_DISABLED); @@ -1216,6 +1268,8 @@ * submission, pass in the $submission variable with the contents of the * submission to be displayed. * + * @param $form + * The current form array (always empty). * @param $form_state * The current form values of a submission, used in multipage webforms. * @param $node @@ -1230,7 +1284,7 @@ * building the form. Values need to be unfiltered to be editable by * Form Builder. */ -function webform_client_form(&$form_state, $node, $submission, $is_draft = FALSE, $filter = TRUE) { +function webform_client_form($form, $form_state, $node, $submission, $is_draft = FALSE, $filter = TRUE) { global $user; // Add a theme function for this form. @@ -1464,7 +1518,7 @@ $display_element['#parents'] = $parents; } if (!isset($display_element['#id'])) { - $display_element['#id'] = form_clean_id('edit-' . implode('-', $display_element['#parents'])); + $display_element['#id'] = drupal_clean_css_identifier('edit-' . implode('-', $display_element['#parents'])); } $parent_fieldset[$component['form_key']] = $display_element; } @@ -1516,7 +1570,7 @@ module_load_include('inc', 'webform', 'includes/webform.submissions'); if ($limit_exceeded = _webform_submission_limit_check($node)) { - $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles())); + $error = theme('webform_view_messages', array('node' => $node, 'teaser' => 0, 'pager' => 1, 'submission_count' => 0, 'limit_exceeded' => $limit_exceeded, 'allowed_roles' => array_keys(user_roles()))); form_set_error('', $error); return; } @@ -1729,13 +1783,13 @@ } // Check if user is submitting as a draft. - $is_draft = $form_state['values']['op'] == $draft_op; + $is_draft = (int) ($form_state['values']['op'] == $draft_op); // Create a submission object. $submission = (object) array( 'nid' => $node->nid, 'uid' => $user->uid, - 'submitted' => time(), + 'submitted' => REQUEST_TIME, 'remote_addr' => ip_address(), 'is_draft' => $is_draft, 'data' => webform_submission_data($node, $form_state['values']['submitted']), @@ -1780,7 +1834,7 @@ // Pass through the theme layer if using the default template. if ($email['template'] == 'default') { - $email['message'] = theme(array('webform_mail_' . $node->nid, 'webform_mail', 'webform_mail_message'), $node, $submission, $cid); + $email['message'] = theme(array('webform_mail_' . $node->nid, 'webform_mail', 'webform_mail_message'), array('node' => $node, 'submission' => $submission, 'cid' => $cid)); } else { $email['message'] = $email['template']; @@ -1790,7 +1844,7 @@ $email['message'] = _webform_filter_values($email['message'], $node, $submission, $email, FALSE, TRUE); // Build the e-mail headers. - $email['headers'] = theme(array('webform_mail_headers_' . $node->nid, 'webform_mail_headers'), $node, $submission, $cid); + $email['headers'] = theme(array('webform_mail_headers_' . $node->nid, 'webform_mail_headers'), array('node' => $node, 'submission' => $submission, 'cid' => $cid)); // Assemble the FROM string. if (isset($email['headers']['From'])) { @@ -1901,10 +1955,10 @@ elseif ($redirect_url && strpos($redirect_url, 'http') !== 0) { $parts = parse_url($redirect_url); $query = $parts['query'] ? ($parts['query'] . '&sid=' . $sid) : ('sid=' . $sid); - $redirect = array($parts['path'], $query, $parts['fragment']); + $redirect = array($parts['path'], array('query' => $query, 'fragment' => $parts['fragment'])); } else { - $redirect = array('node/' . $node->nid . '/done', 'sid=' . $sid); + $redirect = array('node/' . $node->nid . '/done', array('query' => array('sid' => $sid))); } // Show a message if manually set. @@ -1979,10 +2033,10 @@ * Prints the confirmation message after a successful submission. */ function _webform_confirmation($node) { - drupal_set_title(check_plain($node->title)); + drupal_set_title($node->title); webform_set_breadcrumb($node); if (empty($output)) { - $output = theme(array('webform_confirmation_' . $node->nid, 'webform_confirmation'), $node, $_GET['sid']); + $output = theme(array('webform_confirmation_' . $node->nid, 'webform_confirmation'), array('node' => $node, 'sid' => $_GET['sid'])); } return $output; } @@ -2019,24 +2073,12 @@ } /** - * A Form API #post_render function. Wraps displayed elements in their label. - * - * Note: this entire function may be removed in Drupal 7, which supports - * #theme_wrappers natively. - */ -function webform_element_wrapper($content, $elements) { - if (isset($elements['#theme_wrappers'])) { - foreach ($elements['#theme_wrappers'] as $theme_wrapper) { - $content = theme($theme_wrapper, $elements, $content); - } - } - return $content; -} - -/** * Replacement for theme_form_element(). */ -function theme_webform_element($element, $value) { +function theme_webform_element($variables) { + $element = $variables['element']; + $value = $variables['element']['#children']; + $wrapper_classes = array( 'form-item', $element['#format'] == 'html' ? 'webform-display-item' : 'webform-item', @@ -2063,7 +2105,10 @@ /** * Output a form element in plain text format. */ -function theme_webform_element_text($element, $value) { +function theme_webform_element_text($variables) { + $element = $variables['element']; + $value = $variables['element']['#children']; + $output = ''; // Output the element title. @@ -2131,7 +2176,7 @@ * for "From", "To", or "Subject" are set, they will take precedence over * the values set in the webform configuration. */ -function theme_webform_mail_headers($node, $submission, $cid) { +function theme_webform_mail_headers($variables) { $headers = array( 'X-Mailer' => 'Drupal Webform (PHP/' . phpversion() . ')', ); @@ -2142,12 +2187,14 @@ * Check if current user has a draft of this webform, and return the sid. */ function _webform_fetch_draft_sid($nid, $uid) { - $result = db_query("SELECT * FROM {webform_submissions} WHERE nid = %d AND uid = %d AND is_draft = 1 ORDER BY submitted DESC", $nid, $uid); - $row = db_fetch_array($result); - if (isset($row['sid'])) { - return (int) $row['sid']; - } - return FALSE; + return db_select('webform_submissions') + ->fields('webform_submissions', array('sid')) + ->condition('nid', $nid) + ->condition('uid', $uid) + ->condition('is_draft', 1) + ->orderBy('submitted', 'DESC') + ->execute() + ->fetchField(); } /** @@ -2187,7 +2234,7 @@ if (!isset($replacements)) { $replacements['unsafe'] = array(); $replacements['safe']['%site'] = variable_get('site_name', 'drupal'); - $replacements['safe']['%date'] = format_date(time(), 'large'); + $replacements['safe']['%date'] = format_date(REQUEST_TIME, 'large'); } // Node replacements. @@ -2356,7 +2403,7 @@ return $result; } -function theme_webform_token_help($node = NULL) { +function theme_webform_token_help($variables) { $basic_tokens = array( '%username', '%useremail', @@ -2390,11 +2437,11 @@ $output .= '

' . t('You may use special tokens in this field that will be replaced with dynamic values.') . '

'; if (!empty($submission_tokens)) { - $output .= theme('item_list', $submission_tokens, t('Component variables')); + $output .= theme('item_list', array('items' => $submission_tokens, 'title' => t('Component variables'))); } - $output .= theme('item_list', $basic_tokens, t('Basic variables')); - $output .= theme('item_list', $special_tokens, t('Special variables')); + $output .= theme('item_list', array('items' => $basic_tokens, 'title' => t('Basic variables'))); + $output .= theme('item_list', array('items' => $special_tokens, 'title' => t('Special variables'))); $output .= '

' . t('You can use %server[key] to add any of the special PHP $_SERVER variables, %session[key] to add any of the special PHP $_SESSION variables and %get[key] to create prefilled forms from the URL. %cookie, %request and %post also work with their respective PHP variables. For example %server[HTTP_USER_AGENT], %session[id], or %get[q].') . '

'; if (module_exists('profile')) { $output .= '

' . t('If you are using the Profile module, you can also access all profile data using the syntax %profile[form_name]. If you for example have a profile value named profile_city, add the variable %profile[profile_city].') . '

'; @@ -2406,8 +2453,9 @@ '#collapsible' => TRUE, '#collapsed' => TRUE, '#children' => '
' . $output . '
', + '#attributes' => array('class' => array('collapsible', 'collapsed')), ); - return theme('fieldset', $fieldset); + return theme('fieldset', array('element' => $fieldset)); } function _webform_safe_name($name) { Index: webform_hooks.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform_hooks.php,v retrieving revision 1.9 diff -u -r1.9 webform_hooks.php --- webform_hooks.php 20 Feb 2010 21:01:01 -0000 1.9 +++ webform_hooks.php 8 Mar 2010 00:55:53 -0000 @@ -488,7 +488,7 @@ */ function _webform_help_component($section) { switch ($section) { - case 'admin/settings/webform#grid_description': + case 'admin/config/content/webform#grid_description': return t('Allows creation of grid questions, denoted by radio buttons.'); } } @@ -566,7 +566,7 @@ } $rows[] = $row; } - $output = theme('table', $header, $rows, array('class' => 'webform-grid')); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('webform-grid')))); return array(array(array('data' => $output, 'colspan' => 2))); } Index: webform.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.info,v retrieving revision 1.5 diff -u -r1.5 webform.info --- webform.info 10 Feb 2010 01:16:49 -0000 1.5 +++ webform.info 8 Mar 2010 00:55:51 -0000 @@ -1,5 +1,36 @@ ; $Id: $ name = Webform description = Enables the creation of forms and questionnaires. -core = 6.x +core = 7.x package = Webform +files[] = webform.module +files[] = webform.install + +files[] = components/date.inc +files[] = components/email.inc +files[] = components/fieldset.inc +files[] = components/file.inc +files[] = components/grid.inc +files[] = components/hidden.inc +files[] = components/markup.inc +files[] = components/pagebreak.inc +files[] = components/select.inc +files[] = components/textarea.inc +files[] = components/textfield.inc +files[] = components/time.inc + +files[] = includes/webform.admin.inc +files[] = includes/webform.components.inc +files[] = includes/webform.emails.inc +files[] = includes/webform.export.inc +files[] = includes/webform.form_builder.inc +files[] = includes/webform.pages.inc +files[] = includes/webform.report.inc +files[] = includes/webform.submissions.inc + +files[] = views/webform_handler_field_form_body.inc +files[] = views/webform_handler_field_is_draft.inc +files[] = views/webform_handler_field_submission_count.inc +files[] = views/webform_handler_field_submission_link.inc +files[] = views/webform_handler_filter_is_draft.inc +files[] = views/webform.views.inc \ No newline at end of file Index: webform.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v retrieving revision 1.41 diff -u -r1.41 webform.install --- webform.install 3 Mar 2010 02:51:37 -0000 1.41 +++ webform.install 8 Mar 2010 00:55:52 -0000 @@ -351,7 +351,7 @@ 'modified' => TRUE, 'locked' => FALSE, ); - $webform_type = (object) _node_type_set_defaults($webform_type); + $webform_type = (object) node_type_set_defaults($webform_type); node_type_save($webform_type); } @@ -370,7 +370,7 @@ $component_list = array(); $path = drupal_get_path('module', 'webform') . '/components'; - $files = file_scan_directory($path, '^.*\.inc$'); + $files = file_scan_directory($path, '/^.*\.inc$/'); foreach ($files as $filename => $file) { variable_del('webform_enable_' . $file->name, 1); } @@ -390,247 +390,32 @@ * but prevent updates from any version prior to Webform 1.10. */ function webform_update_last_removed() { - return 20; -} - -/** - * Upgrade to Drupal 6. Convert submissions sid column to auto-increment. - */ -function webform_update_6001() { - $ret = array(); - // Keys must be dropped before altering the column. - db_drop_primary_key($ret, 'webform_submissions'); - db_drop_unique_key($ret, 'webform_submissions', 'sid_nid'); - - // Alter to a primary key and add the unique key back. - db_change_field($ret, 'webform_submissions', 'sid', 'sid', array('type' => 'serial', 'not null' => TRUE), array('primary key' => array('sid'))); - db_add_unique_key($ret, 'webform_submissions', 'sid_nid', array('sid', 'nid')); - return $ret; -} - -/** - * Increase the size of the component instance name. - */ -function webform_update_6200() { - $ret = array(); - db_change_field($ret, 'webform_component', 'name', 'name', array('type' => 'varchar', 'length' => 255, 'default' => 'NULL')); - return $ret; -} - -/** - * Add a column for email to the webform_component table. - */ -function webform_update_6201() { - $ret = array(); - - // This update will already be run as webform_update_5201 on Drupal 5. - if (db_column_exists('webform_component', 'email')) { - return $ret; - } - - db_add_field($ret, 'webform_component', 'email', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - $ret[] = update_sql('UPDATE {webform_component} SET email = 1'); - - return $ret; -} - -/** - * Per-webform submission access control based on roles. - */ -function webform_update_6202() { - $ret = array(); - - // This update will already be run as webform_update_5202 on Drupal 5. - if (db_table_exists('webform_roles')) { - return $ret; - } - - db_create_table($ret, 'webform_roles', array( - 'description' => 'Holds access information regarding which roles are allowed to submit which webform nodes. Does not prevent access to the webform node entirely, use the {node_access} table for that purpose.', - 'fields' => array( - 'nid' => array( - 'description' => 'The node identifier of a webform.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'rid' => array( - 'description' => 'The role identifier.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'primary key' => array('nid', 'rid'), - )); - - $result = db_query("SELECT nid FROM {node} WHERE type = 'webform'"); - while ($node = db_fetch_object($result)) { - db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 1)", $node->nid); - db_query("INSERT INTO {webform_roles} (nid, rid) VALUES (%d, 2)", $node->nid); - } - - return $ret; -} - -/** - * Cleanup filtering values used by the file component. - * - * Previously, file extensions were saved by category, exactly as the FormAPI - * returned to the submit handler. All extensions are now stored in a single - * array, including only valid extensions. - */ -function webform_update_6203() { - $ret = array(); - - // This update will already be run as webform_update_5203 on Drupal 5. - - $result = db_query("SELECT nid, cid, extra FROM {webform_component} WHERE type = 'file'"); - while ($component = db_fetch_object($result)) { - $extra = unserialize($component->extra); - $extensions = array(); - - // Sanity check, set some defaults if no filtering is in place. - if (!isset($extra['filtering']['types'])) { - $extra['filtering']['types'] = array( - 'webimages' => drupal_map_assoc(array('png', 'gif', 'jpg')), - ); - } - // Or if filtering has already been updated, skip this update. - elseif (!isset($extra['filtering']['types']['webimages'])) { - continue; - } - - // Defined types. - foreach ($extra['filtering']['types'] as $category => $category_extensions) { - foreach ((array)$category_extensions as $extension) { - if (!is_numeric($extension)) { - $extensions[] = $extension; - } - } - } - - // Additional types. - $additional_extensions = explode(',', $extra['filtering']['addextensions']); - foreach ($additional_extensions as $extension) { - $clean_extension = drupal_strtolower(trim($extension)); - if (!empty($clean_extension) && !in_array($clean_extension, $extensions)) { - $extensions[] = $clean_extension; - } - } - - $extra['filtering']['types'] = $extensions; - db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = %d AND cid = %d", serialize($extra), $component->nid, $component->cid); - } - - return $ret; -} - -/** - * Set all files to permanent status uploaded by Webform. - */ -function webform_update_6204() { - $ret = array(); - $ret[] = update_sql("UPDATE {files} SET status = 1 WHERE filepath LIKE '" . file_directory_path() . "/webform/%'"); - return $ret; -} - -/** - * Schema fixes to make Drupal 5 upgrades identical to clean Drupal 6 installs. - */ -function webform_update_6205() { - $ret = array(); - - // Remove disp-width and default from webform.nid. - db_drop_primary_key($ret, 'webform'); - db_change_field($ret, 'webform', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('nid'))); - - // Set not null property on webform.confirmation. - db_change_field($ret, 'webform', 'confirmation', 'confirmation', array('type' => 'text', 'not null' => TRUE)); - - // Set size to tiny, remove disp-width on webform.submit_limit. - db_change_field($ret, 'webform', 'submit_limit', 'submit_limit', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => -1)); - - // Set default value to -1, remove disp-width on webform.submit_interval. - db_change_field($ret, 'webform', 'submit_interval', 'submit_interval', array('type' => 'int', 'not null' => TRUE, 'default' => -1)); - - // Set not null property on webform.additional_validate. - db_change_field($ret, 'webform', 'additional_validate', 'additional_validate', array('type' => 'text', 'not null' => TRUE)); - - // Set not null property on webform.additional_submit. - db_change_field($ret, 'webform', 'additional_submit', 'additional_submit', array('type' => 'text', 'not null' => TRUE)); - - // Set not null property, default on webform_component.name. - db_change_field($ret, 'webform_component', 'name', 'name', array('type' => 'varchar', 'length' => 255)); - - // Set not null property on webform_component.value. - db_change_field($ret, 'webform_component', 'value', 'value', array('type' => 'text', 'not null' => TRUE)); - - // Set not null property on webform_component.extra. - db_change_field($ret, 'webform_component', 'extra', 'extra', array('type' => 'text', 'not null' => TRUE)); - - // Set column size, disp-width on webform_component.mandatory. - db_change_field($ret, 'webform_component', 'mandatory', 'mandatory', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - - // Set column size, disp-width, not null property on webform_component.weight. - db_change_field($ret, 'webform_component', 'weight', 'weight', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)); - - // Set unsigned, not null property on webform_submissions.sid. - db_drop_unique_key($ret, 'webform_submissions', 'sid_nid'); - db_change_field($ret, 'webform_submissions', 'sid', 'sid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE)); - db_drop_primary_key($ret, 'webform_submissions'); - db_change_field($ret, 'webform_submissions', 'sid', 'sid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('sid'), 'unique keys' => array('sid_nid' => array('sid', 'nid')))); - - // Temporarily drop all keys from the webform_submitted_data table for changes. - db_drop_primary_key($ret, 'webform_submitted_data'); - db_drop_index($ret, 'webform_submitted_data', 'nid'); - db_drop_index($ret, 'webform_submitted_data', 'sid_nid'); - - // Set unsigned, size on webform_submitted_data.no. - db_change_field($ret, 'webform_submitted_data', 'no', 'no', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - - // Set size, not null property on webform_submitted_data.data. - db_change_field($ret, 'webform_submitted_data', 'data', 'data', array('type' => 'text', 'size' => 'medium', 'not null' => TRUE)); - - // Set correct keys. - db_add_primary_key($ret, 'webform_submitted_data', array('nid', 'sid', 'cid', 'no')); - db_add_index($ret, 'webform_submitted_data', 'nid', array('nid')); - db_add_index($ret, 'webform_submitted_data', 'sid_nid', array('sid', 'nid')); - - return $ret; + return 6205; } /** * Add a separate column for confirmation message input format. */ function webform_update_6301() { - $ret = array(); - // Safety check to prevent re-adding existing column. if (db_column_exists('webform', 'confirmation_format')) { - return $ret; + return; } - db_add_field($ret, 'webform', 'confirmation_format', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); + db_add_field('webform', 'confirmation_format', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); $result = db_query("SELECT n.nid, nr.format FROM {node} n INNER JOIN {node_revisions} nr ON n.vid = nr.vid WHERE n.type = 'webform'"); while ($node = db_fetch_object($result)) { - db_query('UPDATE {webform} SET confirmation_format = %d WHERE nid = %d', $node->format, $node->nid); + db_query('UPDATE {webform} SET confirmation_format = :confirmation_format WHERE nid = :nid', array('confirmation_format' => $node->format, 'nid' => $node->nid)); } - - return $ret; } /** * Convert node-level e-mail settings to new webform_emails table. */ function webform_update_6302() { - $ret = array(); - // Safety check to prevent recreating the webform_emails table. if (db_table_exists('webform_emails')) { - return $ret; + return; } $table = array( @@ -675,19 +460,19 @@ 'primary key' => array('nid', 'eid'), ); - db_create_table($ret, 'webform_emails', $table); + db_create_table('webform_emails', $table); // Move over data from the webform table. $result = db_query("SELECT w.nid, w.email, w.email_from_name, w.email_from_address, w.email_subject, wc.cid, wc.extra FROM {webform} w LEFT JOIN {webform_component} wc ON w.nid = wc.nid AND type IN ('select', 'hidden', 'email') ORDER BY nid"); $nid = 0; - while ($row = db_fetch_object($result)) { + foreach ($result->execute() as $row) { // Insert an e-mail settings row for the default e-mail. if ($row->nid != $nid) { $nid = $row->nid; $eid = 0; if (!empty($row->email)) { $eid++; - db_query("INSERT INTO {webform_emails} (nid, eid, email, subject, from_name, from_address, template) VALUES (%d, %d, '%s', '%s', '%s', '%s', 'default')", $nid, $eid, $row->email, $row->email_subject, $row->email_from_name, $row->email_from_address); + db_query("INSERT INTO {webform_emails} (nid, eid, email, subject, from_name, from_address, template) VALUES (:nid, :eid, :email, :subject, :from, :address, 'default')", array(':nid' => $nid, ':eid' => $eid, ':email' => $row->email, ':subject' => $row->email_subject, ':from' => $row->email_from_name, ':address' => $row->email_from_address)); } } @@ -697,49 +482,41 @@ if ($extra['email']) { $eid++; unset($extra['email']); - db_query("INSERT INTO {webform_emails} (nid, eid, email, subject, from_name, from_address, template) VALUES (%d, %d, '%s', '%s', '%s', '%s', 'default')", $nid, $eid, $row->cid, $row->email_subject, $row->email_from_name, $row->email_from_address); - db_query("UPDATE {webform_component} SET extra = '%s' WHERE nid = %d AND cid = %d", serialize($extra), $row->nid, $row->cid); + db_query("INSERT INTO {webform_emails} (nid, eid, email, subject, from_name, from_address, template) VALUES (:nid, :eid, :cid, :subject, :from, :address, 'default')", array(':nid' => $nid, ':eid' => $eid, ':cid' => $row->cid, ':subject' => $row->email_subject, ':from' => $row->email_from_name, ':address' => $row->email_from_address)); + db_query("UPDATE {webform_component} SET extra = :extra WHERE nid = :nid AND cid = :cid", array(':extra' => serialize($extra), ':nid' => $row->nid, ':cid' => $row->cid)); } } } // Remove columns from webform table. - db_drop_field($ret, 'webform', 'email'); - db_drop_field($ret, 'webform', 'email_from_name'); - db_drop_field($ret, 'webform', 'email_from_address'); - db_drop_field($ret, 'webform', 'email_subject'); - - return $ret; + db_drop_field('webform', 'email'); + db_drop_field('webform', 'email_from_name'); + db_drop_field('webform', 'email_from_address'); + db_drop_field('webform', 'email_subject'); } /** * Add the submit_notice field and update all existing webforms to the 2.x previous submissions notice default. */ function webform_update_6303() { - $ret = array(); - db_add_field($ret, 'webform', 'submit_notice', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - $ret[] = update_sql("UPDATE {webform} SET submit_notice = 1 WHERE submit_notice = 0"); - return $ret; + db_add_field('webform', 'submit_notice', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); + db_query("UPDATE {webform} SET submit_notice = 1 WHERE submit_notice = 0"); } /** * Convert the webform content type to be owned by Node module. */ function webform_update_6304() { - $ret = array(); - $ret[] = update_sql("UPDATE {node_type} SET module = 'node', custom = 1, modified = 1, locked = 0 WHERE type = 'webform'"); + db_query("UPDATE {node_type} SET module = 'node', custom = 1, modified = 1, locked = 0 WHERE type = 'webform'"); if (!db_affected_rows()) { - $ret[] = update_sql("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('webform', 'Webform', 'node', 'Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'webform')"); + db_query("INSERT INTO {node_type} (type, name, module, description, help, has_title, title_label, has_body, body_label, min_word_count, custom, modified, locked, orig_type) VALUES ('webform', 'Webform', 'node', 'Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'webform')"); } - return $ret; } /** * Migrate the renamed permissions. Add separate permissions for delete. */ function webform_update_6305() { - $ret = array(); - $updated_permissions = array( 'create webforms' => array('add webform content'), 'edit own webforms' => array('edit own webform content', 'delete own webform content'), @@ -750,64 +527,50 @@ 'clear webform results' => array('delete all webform submissions'), ); - $result = db_query("SELECT * FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid"); - while ($role = db_fetch_object($result)) { - $role->perm = drupal_map_assoc(explode(', ', $role->perm)); - foreach ($updated_permissions as $old => $new) { - if (isset($role->perm[$old])) { - unset($role->perm[$old]); - foreach ($new as $perm) { - $role->perm[$perm] = $perm; - } + foreach ($updated_permissions as $old_perm => $new_perms) { + $result = db_query("SELECT * FROM {user_permission} WHERE permission = :old_perm", array(':old_perm' => $old_perm)); + foreach ($result->execute() as $permission) { + foreach ($new_perms as $new_perm) { + db_query("INSERT INTO {permission} (rid, permission, module) VALUES (:rid, :permission, 'webform')", array(':rid' => $permission->rid, ':permission' => $new_perm)); } } - $ret[] = update_sql("UPDATE {permission} SET perm = '" . implode(', ', $role->perm) . "' WHERE rid = " . $role->rid); } - - return $ret; } /** * Add the ability to save as draft. */ function webform_update_6306() { - $ret = array(); - db_add_field($ret, 'webform', 'allow_draft', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - db_add_field($ret, 'webform_submissions', 'is_draft', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); - return $ret; + if (!db_column_exists('webform', 'allow_draft')) { + db_add_field('webform', 'allow_draft', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); + db_add_field('webform_submissions', 'is_draft', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0)); + } } /** * Convert the file component to use only FIDs instead of serialized arrays. */ function webform_update_6307() { - $ret = array(); - $result = db_query("SELECT d.*, s.uid, s.submitted FROM {webform_submitted_data} d INNER JOIN {webform_component} c ON d.cid = c.cid AND d.nid = c.nid AND c.type = 'file' INNER JOIN {webform_submissions} s ON d.sid = s.sid"); - while ($row = db_fetch_object($result)) { + foreach ($result->execute() as $row) { $file = @unserialize($row->data); // File name should always exist, even when upgrading from Drupal 5. if ($file && isset($file['filename'])) { // Create an entry in the files table if needed. if (!isset($file['fid'])) { - db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (%d, %d, '%s', '%s', '%s', %d, 1, %d)", $row->uid, $file['filename'], $file['filepath'], $file['filemime'], $file['filesize'], $row->submitted); - $fid = db_last_insert_id('files', 'fid'); + $fid = db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (:uid, :filename, :filepath, :filemime, :filesize, 1, :timestamp)", array(':uid' => $row->uid, ':filename' => $file['filename'], ':filepath' => $file['filepath'], ':filemime' => $file['filemime'], ':filesize' => $file['filesize'], ':timestamp' => $row->submitted)); } else { $fid = $file['fid']; } // Update the submitted data with the FID. - db_query("UPDATE {webform_submitted_data} SET data = '%d' WHERE nid = %d AND sid = %d AND cid = %d", $fid, $row->nid, $row->sid, $row->cid); + db_query("UPDATE {webform_submitted_data} SET data = :fid WHERE nid = :nid AND sid = :sid AND cid = :cid", array(':fid' => $fid, ':nid' => $row->nid, ':sid' => $row->sid, ':cid' => $row->cid)); } // Insert an empty entry, now just an empty string. else { - db_query("UPDATE {webform_submitted_data} SET data = '' WHERE nid = %d AND sid = %d AND cid = %d", $row->nid, $row->sid, $row->cid); + db_query("UPDATE {webform_submitted_data} SET data = '' WHERE nid = :nid AND sid = :sid AND cid = :cid", array(':nid' => $row->nid, ':sid' => $row->sid, ':cid' => $row->cid)); } } - - $ret[] = array('success' => TRUE, 'query' => t('Updated file components to use numeric file IDs in the submitted values.')); - - return $ret; } /** @@ -823,10 +586,10 @@ $result = db_query("SELECT nid, cid FROM {webform_component} WHERE email = 0 ORDER BY nid"); $nid = 0; $excluded_components = array(); - while ($row = db_fetch_object($result)) { + foreach ($result->execute() as $row) { if ($nid != $row->nid) { if (!empty($excluded_components)) { - db_query("UPDATE {webform_emails} SET excluded_components = '%s' WHERE nid = %d", implode(',', $excluded_components), $nid); + db_query("UPDATE {webform_emails} SET excluded_components = :exclude WHERE nid = :nid", array(':exclude' => implode(',', $excluded_components), ':nid' => $nid)); } $nid = $row->nid; $excluded_components = array(); @@ -836,64 +599,47 @@ // One last query for the last form in the list. if (!empty($excluded_components)) { - db_query("UPDATE {webform_emails} SET excluded_components = '%s' WHERE nid = %d", implode(',', $excluded_components), $nid); + db_query("UPDATE {webform_emails} SET excluded_components = :excluded WHERE nid = :nid", array(':exclude' => implode(',', $excluded_components), ':nid' => $nid)); } - db_drop_field($ret, 'webform_component', 'email'); - - return $ret; + db_drop_field('webform_component', 'email'); } /** * Fix permissions for all roles by adding an additional space after comma. */ function webform_update_6309() { - $ret = array(); - - $result = db_query("SELECT r.rid, p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid"); - while ($role = db_fetch_object($result)) { - $perms = explode(',', $role->perm); - foreach ($perms as $id => $perm) { - $perms[$id] = trim($perm); - } - $ret[] = update_sql("UPDATE {permission} SET perm = '" . implode(', ', $perms) . "' WHERE rid = " . $role->rid); - } - - return $ret; + // This update is not needed in the D6 -> D7 upgrade. } /** * Add the redirect_url field and update existing webforms to use it. */ function webform_update_6310() { - $ret = array(); - // Safety check to prevent re-adding existing column. if (db_column_exists('webform', 'redirect_url')) { - return $ret; + return; } // Add the new redirect_url column. - db_add_field($ret, 'webform', 'redirect_url', array('type' => 'varchar', 'length' => '255')); + db_add_field('webform', 'redirect_url', array('type' => 'varchar', 'length' => '255')); // If the webform is using the confirmation field as a redirect then move it // to the new redirect_url field. $result = db_query("SELECT nid, confirmation FROM {webform}"); - while ($row = db_fetch_object($result)) { + foreach ($result->execute() as $row) { $confirmation = trim(strip_tags($row->confirmation, '')); if (valid_url($confirmation, TRUE) || preg_match('/^internal:/', $confirmation)) { $redirect_url = preg_replace('/^internal:/', '', $confirmation); - db_query("UPDATE {webform} SET redirect_url = '%s' WHERE nid = %d", $redirect_url, $row->nid); - db_query("UPDATE {webform} SET confirmation = '' WHERE nid = %d", $row->nid); + db_query("UPDATE {webform} SET redirect_url = :redirect_url WHERE nid = :nid", array(':redirect_url' => $redirect_url, ':nid' => $row->nid)); + db_query("UPDATE {webform} SET confirmation = '' WHERE nid = :nid", array(':nid' => $row->nid)); } elseif (preg_match('/^message:/', $confirmation)) { $message = preg_replace('/^message:/', '', $confirmation); - db_query("UPDATE {webform} SET redirect_url = '%s' WHERE nid = %d", 'node/' . $row->nid, $row->nid); - db_query("UPDATE {webform} SET confirmation = '%s' WHERE nid = %d", $message, $row->nid); + db_query("UPDATE {webform} SET redirect_url = :redirect_url WHERE nid = :nid", array(':redirect_url' => 'node/' . $row->nid, ':nid' => $row->nid)); + db_query("UPDATE {webform} SET confirmation = :confirmation WHERE nid = :nid", array(':confirmation' => $message, ':nid' => $row->nid)); } } - - return $ret; } /** Index: webform.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.js,v retrieving revision 1.6 diff -u -r1.6 webform.js --- webform.js 23 Jan 2010 06:25:09 -0000 1.6 +++ webform.js 8 Mar 2010 00:55:52 -0000 @@ -1,10 +1,12 @@ // $Id: webform.js,v 1.6 2010/01/23 06:25:09 quicksketch Exp $ +(function ($) { /** * Webform node form interface enhancments. */ -Drupal.behaviors.webform = function(context) { +Drupal.behaviors.webform = {}; +Drupal.behaviors.webform.attach = function(context) { // Apply special behaviors to fields with default values. Drupal.webform.defaultValues(context); // On click or change, make a parent radio button selected. @@ -90,3 +92,4 @@ }); } +})(jQuery); Index: components/textfield.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textfield.inc,v retrieving revision 1.22 diff -u -r1.22 textfield.inc --- components/textfield.inc 3 Mar 2010 02:51:37 -0000 1.22 +++ components/textfield.inc 8 Mar 2010 00:55:54 -0000 @@ -37,7 +37,7 @@ function _webform_theme_textfield() { return array( 'webform_display_textfield' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -170,7 +170,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_textfield', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#field_prefix' => $component['extra']['field_prefix'], '#field_suffix' => $component['extra']['field_suffix'], '#component' => $component, @@ -222,7 +221,8 @@ /** * Format the output of data for this component. */ -function theme_webform_display_textfield($element) { +function theme_webform_display_textfield($variables) { + $element = $variables['element']; $prefix = $element['#format'] == 'html' ? filter_xss($element['#field_prefix']) : $element['#field_prefix']; $suffix = $element['#format'] == 'html' ? filter_xss($element['#field_suffix']) : $element['#field_suffix']; $value = $element['#format'] == 'html' ? check_plain($element['#value']) : $element['#value']; @@ -233,18 +233,21 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_textfield($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + $nonblanks = 0; $submissions = 0; $wordcount = 0; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - while ($data = db_fetch_array($result)) { + $result = $query->execute(); + foreach ($result as $data) { if (drupal_strlen(trim($data['data'])) > 0) { $nonblanks++; $wordcount += str_word_count(trim($data['data'])); Index: components/time.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v retrieving revision 1.25 diff -u -r1.25 time.inc --- components/time.inc 3 Mar 2010 02:51:37 -0000 1.25 +++ components/time.inc 8 Mar 2010 00:55:54 -0000 @@ -33,10 +33,10 @@ function _webform_theme_time() { return array( 'webform_time' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), 'webform_display_time' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -227,7 +227,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_time', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, '#hourformat' => $component['extra']['hourformat'], @@ -238,7 +237,8 @@ /** * Format the output of data for this component. */ -function theme_webform_display_time($element) { +function theme_webform_display_time($variables) { + $element = $variables['element']; $output = ' '; if ($element['#value']['hour'] && $element['#value']['minute']) { if ($element['#hourformat'] == '24-hour') { @@ -255,19 +255,23 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_time($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT no,data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter . - ' ORDER BY sid,no ASC '; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->orderBy('sid') + ->orderBy('no'); - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - // build an array of timestamps from entered values. + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + + $result = $query->execute(); + + // Build an array of timestamps from entered values. $timestamps = array(); $submissions = 1; - while ($row = db_fetch_array($result)) { + foreach ($result as $row) { if ($row['no'] == '0') { $submissions++; $hour = $row['data']; @@ -354,5 +358,5 @@ $element['#type'] = 'element'; $element['#children'] = '
' . drupal_render($element['hour']) . drupal_render($element['minute']) . drupal_render($element['ampm']) . '
'; - return theme('form_element', $element, $element['#children']); + return $element['#children']; } Index: components/textarea.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textarea.inc,v retrieving revision 1.21 diff -u -r1.21 textarea.inc --- components/textarea.inc 3 Mar 2010 02:51:37 -0000 1.21 +++ components/textarea.inc 8 Mar 2010 00:55:54 -0000 @@ -36,7 +36,7 @@ function _webform_theme_textarea() { return array( 'webform_display_textarea' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -132,7 +132,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_textarea', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, '#value' => isset($value[0]) ? $value[0] : '', @@ -142,7 +141,8 @@ /** * Format the output of data for this component. */ -function theme_webform_display_textarea($element) { +function theme_webform_display_textarea($variables) { + $element = $variables['element']; $output = $element['#format'] == 'html' ? str_replace("\n", '
', check_plain($element['#value'])) : $element['#value']; if (strlen($output) > 80) { $output = ($element['#format'] == 'html') ? '
' . $output . '
' : $output; @@ -193,18 +193,21 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_textarea($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + $nonblanks = 0; $submissions = 0; $wordcount = 0; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - while ($data = db_fetch_array($result)) { + $result = $query->execute(); + foreach ($result as $data) { if (drupal_strlen(trim($data['data'])) > 0) { $nonblanks++; $wordcount += str_word_count(trim($data['data'])); Index: components/date.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v retrieving revision 1.30 diff -u -r1.30 date.inc --- components/date.inc 3 Mar 2010 02:51:37 -0000 1.30 +++ components/date.inc 8 Mar 2010 00:55:53 -0000 @@ -34,10 +34,10 @@ function _webform_theme_date() { return array( 'webform_date' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), 'webform_display_date' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -279,7 +279,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_date', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, '#value' => $value, @@ -289,7 +288,8 @@ /** * Format the text output for this component. */ -function theme_webform_display_date($element) { +function theme_webform_display_date($variables) { + $element = $variables['element']; $output = ' '; if ($element['#value']) { $timestamp = webform_strtotime($element['#value']['month'] . '/' . $element['#value']['day'] . '/' . $element['#value']['year']); @@ -304,19 +304,23 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_date($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT no,data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter . - ' ORDER BY sid,no ASC '; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->orderBy('sid') + ->orderBy('no'); - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - // build an array of timestamps from entered values. + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + + $result = $query->execute(); + + // Build an array of timestamps from entered values. $timestamps = array(); $submissions = 1; - while ($row = db_fetch_array($result)) { + foreach ($result as $row) { if ($row['no'] == '0') { $submissions++; $month = $row['data']; Index: components/fieldset.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/fieldset.inc,v retrieving revision 1.12 diff -u -r1.12 fieldset.inc --- components/fieldset.inc 3 Mar 2010 02:51:37 -0000 1.12 +++ components/fieldset.inc 8 Mar 2010 00:55:53 -0000 @@ -72,7 +72,6 @@ $element = array( '#title' => $component['name'], '#weight' => $component['weight'], - '#post_render' => array('webform_element_wrapper'), '#theme_wrappers' => array('webform_element_text'), ); } Index: components/email.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/email.inc,v retrieving revision 1.29 diff -u -r1.29 email.inc --- components/email.inc 3 Mar 2010 02:51:37 -0000 1.29 +++ components/email.inc 8 Mar 2010 00:55:53 -0000 @@ -174,7 +174,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_email', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, '#value' => isset($value[0]) ? $value[0] : '', @@ -184,7 +183,8 @@ /** * Format the text output for this component. */ -function theme_webform_display_email($element) { +function theme_webform_display_email($variables) { + $element = $variables['element']; $element['#value'] = empty($element['#value']) ? ' ' : $element['#value']; return $element['#format'] == 'html' ? check_plain($element['#value']) : $element['#value']; } @@ -229,18 +229,21 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_email($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + $nonblanks = 0; $submissions = 0; $wordcount = 0; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - while ($data = db_fetch_array($result)) { + $result = $query->execute(); + foreach ($result as $data) { if (drupal_strlen(trim($data['data'])) > 0) { $nonblanks++; $wordcount += str_word_count(trim($data['data'])); Index: components/hidden.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/hidden.inc,v retrieving revision 1.22 diff -u -r1.22 hidden.inc --- components/hidden.inc 3 Mar 2010 02:51:37 -0000 1.22 +++ components/hidden.inc 8 Mar 2010 00:55:54 -0000 @@ -27,7 +27,7 @@ function _webform_theme_hidden() { return array( 'webform_display_hidden' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -81,13 +81,14 @@ '#format' => $format, '#theme' => 'webform_display_hidden', '#theme_wrappers' => $format == 'text' ? array('webform_element_text') : array('webform_element'), - '#post_render' => array('webform_element_wrapper'), '#access' => user_access('edit all webform submissions') || user_access('access all webform results'), ); return $element; } -function theme_webform_display_hidden($element) { +function theme_webform_display_hidden($variables) { + $element = $variables['element']; + return $element['#format'] == 'html' ? check_plain($element['#value']) : $element['#value']; } @@ -129,18 +130,21 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_hidden($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . $sidfilter; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + $nonblanks = 0; $submissions = 0; $wordcount = 0; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - while ($data = db_fetch_array($result)) { + $result = $query->execute(); + foreach ($result as $data) { if ( strlen(trim($data['data'])) > 0 ) { $nonblanks++; $wordcount += str_word_count(trim($data['data'])); Index: components/pagebreak.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/pagebreak.inc,v retrieving revision 1.9 diff -u -r1.9 pagebreak.inc --- components/pagebreak.inc 9 Feb 2010 05:39:08 -0000 1.9 +++ components/pagebreak.inc 8 Mar 2010 00:55:54 -0000 @@ -25,7 +25,7 @@ function _webform_theme_pagebreak() { return array( 'webform_display_pagebreak' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -78,6 +78,8 @@ /** * Format the text output data for this component. */ -function theme_webform_display_pagebreak($element) { +function theme_webform_display_pagebreak($variables) { + $element = $variables['element']; + return $element['#format'] == 'html' ? '

' . check_plain($element['#title']) . '

' : "--" . $element['#title'] . "--\n"; } Index: components/file.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/file.inc,v retrieving revision 1.18 diff -u -r1.18 file.inc --- components/file.inc 3 Mar 2010 02:51:37 -0000 1.18 +++ components/file.inc 8 Mar 2010 00:55:54 -0000 @@ -37,13 +37,13 @@ function _webform_theme_file() { return array( 'webform_edit_file' => array( - 'arguments' => array('form' => NULL), + 'render element' => 'form', ), 'webform_render_file' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), 'webform_display_file' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -191,7 +191,9 @@ form_set_value($element['types'], $extensions, $form_state); } -function theme_webform_edit_file($form) { +function theme_webform_edit_file($variables) { + $form = $variables['form']; + // Add a little javascript to check all the items in one type. $javascript = ' '; - drupal_set_html_head($javascript); + drupal_add_html_head($javascript); // Format the components into a table. $per_row = 6; @@ -267,7 +269,9 @@ // Create the table inside the form. $form['validation']['filtering']['types']['table'] = array( - '#value' => theme('table', $header, $rows) + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows ); $output = drupal_render($form); @@ -329,7 +333,9 @@ /** * Render a File component. */ -function theme_webform_render_file($element) { +function theme_webform_render_file($variables) { + $element = $variables['element']; + // Add information about the existing file, if any. $value = $element['_fid']['#value'] ? $element['_fid']['#value'] : $element['_old']['#value']; if ($value && ($file = webform_get_file($value))) { @@ -456,7 +462,8 @@ if ($value['_fid'] && ($file = webform_get_file($value['_fid']))) { // Save any new files permanently. - file_set_status($file, FILE_STATUS_PERMANENT); + $file->status = FILE_STATUS_PERMANENT; + file_save($file); // Delete any previous files. if ($value['_old'] && ($existing = webform_get_file($value['_old']))) { @@ -484,7 +491,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_file', '#theme_wrappers' => $format == 'text' ? array('webform_element_text') : array('webform_element'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, ); @@ -493,7 +499,9 @@ /** * Format the output of text data for this component */ -function theme_webform_display_file($element) { +function theme_webform_display_file($variables) { + $element = $variables['element']; + $file = $element['#value']; $url = !empty($file) ? webform_file_url($file->filepath) : t('no upload'); return !empty($file) ? ($element['#format'] == 'text' ? $url : l($file->filename, $url)) : ' '; @@ -514,18 +522,21 @@ * Implementation of _webform_analysis_component(). */ function _webform_analysis_file($component, $sids = array()) { - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT data ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d' . $sidfilter; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + $nonblanks = 0; $sizetotal = 0; $submissions = 0; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); - while ($data = db_fetch_array($result)) { + $result = $query->execute(); + foreach ($result as $data) { $file = webform_get_file($data['data']); if (isset($file->filesize)) { $nonblanks++; Index: components/grid.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/grid.inc,v retrieving revision 1.15 diff -u -r1.15 grid.inc --- components/grid.inc 3 Mar 2010 02:51:37 -0000 1.15 +++ components/grid.inc 8 Mar 2010 00:55:54 -0000 @@ -37,10 +37,10 @@ function _webform_theme_grid() { return array( 'webform_grid' => array( - 'arguments' => array('grid_element' => NULL), + 'render element' => 'grid_element', ), 'webform_display_grid' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -158,7 +158,6 @@ '#options' => $options, '#theme' => 'webform_display_grid', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#sorted' => TRUE, ); @@ -179,7 +178,9 @@ /** * Format the text output for this component. */ -function theme_webform_display_grid($element) { +function theme_webform_display_grid($variables) { + $element = $variables['element']; + $component = $element['#component']; $format = $element['#format']; @@ -204,7 +205,7 @@ } $option_count = count($header) - 1; - $output = theme('table', $header, $rows, array('class' => 'webform-grid webform-grid-' . $option_count)); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('webform-grid', 'webform-grid-' . $option_count)))); } else { $items = array(); @@ -245,17 +246,21 @@ $questions = array_values(_webform_grid_options($component['extra']['questions'])); // Generate a lookup table of results. - $placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); - $sidfilter = count($sids) ? " AND sid in (" . implode(",", $placeholders) . ")" : ""; - $query = 'SELECT no, data, count(data) as datacount ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . - " AND data != '' " . $sidfilter . - ' GROUP BY no, data'; - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids)); + $query = db_select('webform_submitted_data', 'wsd') + ->fields('wsd', array('no', 'data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->condition('data', '', '<>') + ->groupBy('no') + ->groupBy('data'); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + + $result = $query->execute(); $counts = array(); - while ($data = db_fetch_object($result)) { + foreach ($result as $data) { $counts[$data->no][$data->data] = $data->datacount; } @@ -276,7 +281,7 @@ } $rows[] = $row; } - $output = theme('table', $header, $rows, array('class' => 'webform-grid')); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('webform-grid')))); return array(array(array('data' => $output, 'colspan' => 2))); @@ -337,7 +342,9 @@ return $return; } -function theme_webform_grid($element) { +function theme_webform_grid($variables) { + $element = $variables['element']; + $rows = array(); $header = array(array('data' => '', 'class' => 'webform-grid-question')); $first = TRUE; @@ -365,7 +372,7 @@ } $option_count = count($header) - 1; - return theme('form_element', $element, theme('table', $header, $rows, array('class' => 'webform-grid webform-grid-' . $option_count))); + return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('class' => array('webform-grid', 'webform-grid-' . $option_count)))); } /** Index: components/markup.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/markup.inc,v retrieving revision 1.14 diff -u -r1.14 markup.inc --- components/markup.inc 3 Mar 2010 02:51:37 -0000 1.14 +++ components/markup.inc 8 Mar 2010 00:55:54 -0000 @@ -17,7 +17,7 @@ 'weight' => 0, 'value' => '', 'extra' => array( - 'format' => FILTER_FORMAT_DEFAULT, + 'format' => filter_default_format(), ), ); } @@ -27,16 +27,14 @@ */ function _webform_edit_markup($component) { $form = array(); - $form['markup']['value'] = array( + $form['value'] = array( '#type' => 'textarea', '#title' => t('Value'), '#default_value' => $component['value'], '#description' => t('Markup allows you to enter custom HTML or PHP logic into your form.') . theme('webform_token_help'), '#weight' => -1, - '#parents' => array('value'), + '#text_format' => $component['extra']['format'], ); - // Add the filter form. - $form['markup']['format'] = filter_form($component['extra']['format'], 0, array('extra', 'format')); // No description for markup. $form['extra']['description'] = array(); @@ -115,7 +113,7 @@ '#title' => t('Markup'), '#type' => 'markup', '#markup' => $default, - '#input_format' => FILTER_FORMAT_DEFAULT, + '#input_format' => filter_default_format(), ), ); Index: components/select.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/select.inc,v retrieving revision 1.40 diff -u -r1.40 select.inc --- components/select.inc 3 Mar 2010 02:51:37 -0000 1.40 +++ components/select.inc 8 Mar 2010 00:55:54 -0000 @@ -36,7 +36,7 @@ function _webform_theme_select() { return array( 'webform_display_select' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', ), ); } @@ -143,7 +143,7 @@ } if (!empty($duplicate_keys)) { - form_error($element, t('Options within the select list must be unique. The following keys have been used multiple times:') . theme('item_list', $duplicate_keys)); + form_error($element, t('Options within the select list must be unique. The following keys have been used multiple times:') . theme('item_list', array('items' => $duplicate_keys))); } } @@ -312,7 +312,6 @@ '#weight' => $component['weight'], '#theme' => 'webform_display_select', '#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'), - '#post_render' => array('webform_element_wrapper'), '#component' => $component, '#format' => $format, '#value' => $value, @@ -459,7 +458,8 @@ /** * Format the text output for this component. */ -function theme_webform_display_select($element) { +function theme_webform_display_select($variables) { + $element = $variables['element']; $component = $element['#component']; // Convert submitted 'safe' values to un-edited, original form. @@ -494,7 +494,7 @@ } if ($element['#format'] == 'html') { - $output = count($items) > 1 ? theme('item_list', $items) : (isset($items[0]) ? $items[0] : ' '); + $output = count($items) > 1 ? theme('item_list', array('items' => $items)) : (isset($items[0]) ? $items[0] : ' '); } else { if (count($items) > 1) { @@ -521,26 +521,33 @@ $sid_placeholders = count($sids) ? array_fill(0, count($sids), "'%s'") : array(); $sid_filter = count($sids) ? " AND sid IN (" . implode(",", $sid_placeholders) . ")" : ""; - $not = $show_other_results ? 'NOT ' : ''; - $placeholders = count($options) ? array_fill(0, count($options), "'%s'") : array(); - $query = 'SELECT data, count(data) as datacount ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . - " AND data != ''" . $sid_filter . - ($placeholders ? ' AND data ' . $not . 'IN (' . implode(',', $placeholders) . ')' : '') . - ' GROUP BY data '; - - $count_query = 'SELECT count(*) as datacount ' . - ' FROM {webform_submitted_data} ' . - ' WHERE nid = %d ' . - ' AND cid = %d ' . - " AND data != ''" . $sid_filter; + $option_operator = $show_other_results ? 'NOT IN' : 'IN'; + $query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->fields('wsd', array('data')) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->condition('data', '', '<>') + ->condition('data', $options, $option_operator) + ->groupBy('data'); + $query->addExpression('COUNT(data)', 'datacount'); + + if (count($sids)) { + $query->condition('sid', $sids, 'IN'); + } + + $count_query = db_select('webform_submitted_data', 'wsd', array('fetch' => PDO::FETCH_ASSOC)) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->condition('data', '', '<>'); + $count_query->addExpression('COUNT(*)', 'datacount'); + if (count($sids)) { + $count_query->condition('sid', $sids, 'IN'); + } - $result = db_query($query, array_merge(array($component['nid'], $component['cid']), $sids, array_keys($options))); + $result = $query->execute(); $rows = array(); $normal_count = 0; - while ($data = db_fetch_array($result)) { + foreach ($result as $data) { $display_option = $single ? $data['data'] : $options[$data['data']]; $rows[$data['data']] = array(_webform_filter_xss($display_option), $data['datacount']); $normal_count += $data['datacount']; @@ -555,7 +562,7 @@ // Add a row for any unknown or user-entered values. if ($component['extra']['other_option'] === 'Y') { - $full_count = db_result(db_query($count_query, array_merge(array($component['nid'], $component['cid']), $sids))); + $full_count = $count_query->execute()->fetchField(); $other_count = $full_count - $normal_count; $display_option = empty($component['extra']['other_text']) ? $component['extra']['other_text'] : t('Other...'); $other_text = $other_count ? $other_count . ' (' . l(t('view'), 'node/' . $component['nid'] . '/webform-results/analysis/' . $component['cid']) . ')' : $other_count; Index: includes/webform.export.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.export.inc,v retrieving revision 1.5 diff -u -r1.5 webform.export.inc --- includes/webform.export.inc 3 Mar 2010 02:51:37 -0000 1.5 +++ includes/webform.export.inc 8 Mar 2010 00:55:55 -0000 @@ -82,9 +82,9 @@ } function set_headers($filename) { - drupal_set_header('Content-Type: application/force-download'); - drupal_set_header('Pragma: public'); - drupal_set_header('Cache-Control: max-age=0'); + drupal_add_http_header('Content-Type', 'application/force-download'); + drupal_add_http_header('Pragma', 'public'); + drupal_add_http_header('Cache-Control', 'max-age=0'); } function bof(&$file_handle) { @@ -146,8 +146,8 @@ $content_type = 'text/csv'; } - drupal_set_header("Content-Type: $content_type"); - drupal_set_header("Content-Disposition: attachment; filename=$filename.$extension"); + drupal_add_http_header('Content-Type', $content_type); + drupal_add_http_header('Content-Disposition', "attachment; filename=$filename.$extension"); } } @@ -163,9 +163,9 @@ } function set_headers($filename) { - drupal_set_header('Content-Type: application/x-msexcel'); - drupal_set_header("Content-Disposition: attachment; filename=$filename.xls"); - drupal_set_header('Pragma: public'); - drupal_set_header('Cache-Control: max-age=0'); + drupal_add_http_header('Content-Type', 'application/x-msexcel'); + drupal_add_http_header('Content-Disposition', "attachment; filename=$filename.xls"); + drupal_add_http_header('Pragma', 'public'); + drupal_add_http_header('Cache-Control', 'max-age=0'); } } Index: includes/webform.report.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.report.inc,v retrieving revision 1.17 diff -u -r1.17 webform.report.inc --- includes/webform.report.inc 3 Mar 2010 02:51:37 -0000 1.17 +++ includes/webform.report.inc 8 Mar 2010 00:55:56 -0000 @@ -23,10 +23,10 @@ $pager_count = $_GET['results']; } - $header = theme('webform_results_submissions_header', $node); + $header = theme('webform_results_submissions_header', array('node' => $node)); if ($user_filter) { if ($user->uid) { - drupal_set_title(t('Submissions for %user', array('%user' => $user->name))); + drupal_set_title(t('Submissions for %user', array('%user' => $user->name)), PASS_THROUGH); } else { drupal_set_title(t('Your submissions')); @@ -40,7 +40,7 @@ $submissions = webform_get_submissions($node->nid, $header, $pager_count); $count = webform_get_submission_count($node->nid); } - return theme('webform_results_submissions', $node, $submissions, $count, $pager_count); + return theme('webform_results_submissions', array('node' => $node, 'submissions' => $submissions, 'count' => $count, 'pager_count' => $pager_count)); } /** @@ -51,7 +51,9 @@ * @param $pager_count * The current number of results displayed per page. */ -function theme_webform_results_per_page($total_count, $pager_count) { +function theme_webform_results_per_page($variables) { + $total_count = $variables['total_count']; + $pager_count = $variables['pager_count']; $output = ''; // Create a list of results-per-page options. @@ -69,7 +71,7 @@ foreach ($counts as $number => $text) { if ($number < $total_count) { - $count_links[] = l($text, $_GET['q'], array('query' => 'results=' . $number, 'attributes' => array('class' => $pager_count == $number ? 'selected' : ''))); + $count_links[] = l($text, $_GET['q'], array('query' => array('results' => $number), 'attributes' => array('class' => $pager_count == $number ? 'selected' : ''))); } } @@ -94,8 +96,9 @@ * This is done in it's own function so that webform can retrieve the header and * use it for sorting the results. */ -function theme_webform_results_submissions_header($node) { +function theme_webform_results_submissions_header($variables) { global $user; + $node = $variables['node']; $columns = array( array('data' => t('#'), 'field' => 'sid', 'sort' => 'asc'), @@ -122,14 +125,18 @@ * @param $pager_count * The number of results to be shown per page. */ -function theme_webform_results_submissions($node, $submissions, $total_count = 0, $pager_count = 0) { +function theme_webform_results_submissions($variables) { global $user; + $node = $variables['node']; + $submissions = $variables['submissions']; + $total_count = $variables['total_count']; + $pager_count = $variables['pager_count']; drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); // This header has to be generated separately so we can add the SQL necessary // to sort the results. - $header = theme('webform_results_submissions_header', $node); + $header = theme('webform_results_submissions_header', array('node' => $node)); $operation_column = end($header); $operation_total = $operation_column['colspan']; @@ -140,7 +147,7 @@ format_date($submission->submitted, 'small'), ); if (user_access('access all webform results') || (user_access('access own webform results') && $user->uid == $node->uid)) { - $row[] = theme('username', $submission); + $row[] = theme('username', array('account' => $submission)); $row[] = $submission->remote_addr; } $row[] = l(t('View'), "node/$node->nid/submission/$sid"); @@ -172,13 +179,13 @@ } $output = ''; - $output .= theme('webform_results_per_page', $total_count, $pager_count); - $output .= theme('table', $header, $rows); + $output .= theme('webform_results_per_page', array('total_count' => $total_count, 'pager_count' => $pager_count)); + $output .= theme('table', array('header' => $header, 'rows' => $rows)); if (arg(2) == 'submissions') { - $output .= theme('links', array('webform' => array('title' => t('Go back to the form'), 'href' => 'node/' . $node->nid))); + $output .= theme('links', array('links' => array('webform' => array('title' => t('Go back to the form'), 'href' => 'node/' . $node->nid)))); } if ($pager_count) { - $output .= theme('pager', NULL, $pager_count, 0); + $output .= theme('pager'); } return $output; } @@ -192,18 +199,18 @@ } // Get all the submissions for the node. - $header = theme('webform_results_table_header', $node); + $header = theme('webform_results_table_header', array('node' => $node)); $submissions = webform_get_submissions($node->nid, $header, $pager_count); $total_count = webform_get_submission_count($node->nid); - $output = theme('webform_results_table', $node, $node->webform['components'], $submissions, $total_count, $pager_count); + $output = theme('webform_results_table', array('node' => $node, 'components' => $node->webform['components'], 'submissions' => $submissions, 'total_count' => $total_count, 'pager_count' => $pager_count)); if ($pager_count) { - $output .= theme('pager', NULL, $pager_count, 0); + $output .= theme('pager'); } return $output; } -function theme_webform_results_table_header($node) { +function theme_webform_results_table_header($variables) { return array( array('data' => t('#'), 'field' => 'sid', 'sort' => 'asc'), array('data' => t('Submitted'), 'field' => 'submitted'), @@ -226,22 +233,28 @@ * @param $pager_count * The number of results to be shown per page. */ -function theme_webform_results_table($node, $components, $submissions, $total_count, $pager_count) { +function theme_webform_results_table($variables) { drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); + $node = $variables['node']; + $components = $variables['components']; + $submissions = $variables['submissions']; + $total_count = $variables['total_count']; + $pager_count = $variables['pager_count']; + $header = array(); $rows = array(); $cell = array(); // This header has to be generated seperately so we can add the SQL necessary. // to sort the results. - $header = theme('webform_results_table_header', $node); + $header = theme('webform_results_table_header', array('node' => $node)); // Generate a row for each submission. foreach ($submissions as $sid => $submission) { $cell[] = l($sid, 'node/' . $node->nid . '/submission/' . $sid); $cell[] = format_date($submission->submitted, 'small'); - $cell[] = theme('username', $submission); + $cell[] = theme('username', array('account' => $submission)); $cell[] = $submission->remote_addr; $component_headers = array(); @@ -268,8 +281,8 @@ $output = ''; - $output .= theme('webform_results_per_page', $total_count, $pager_count); - $output .= theme('table', $header, $rows); + $output .= theme('webform_results_per_page', array('total_count' => $total_count, 'pager_count' => $pager_count)); + $output .= theme('table', array('header' => $header, 'rows' => $rows)); return $output; } @@ -293,7 +306,7 @@ * @param $nid * ID of node for which to clear submissions. */ -function webform_results_clear_form($form_state, $node) { +function webform_results_clear_form($form, $form_state, $node) { drupal_set_title(t('Clear Form Submissions')); $form = array(); @@ -317,7 +330,7 @@ /** * Form to configure the download of CSV files. */ -function webform_results_download_form(&$form_state, $node) { +function webform_results_download_form($form, &$form_state, $node) { module_load_include('inc', 'webform', 'includes/webform.export'); $form = array(); @@ -365,12 +378,12 @@ 'compact' => t('Compact'), ), '#default_value' => 'separate', - '#attributes' => array('class' => 'webform-select-list-format'), + '#attributes' => array('class' => array('webform-select-list-format')), '#theme' => 'webform_results_download_select_format', ); $csv_components = array( - '' => t('Submission information'), + 'info' => t('Submission information'), 'serial' => '-' . t('Submission Number'), 'sid' => '-' . t('Submission ID'), 'time' => '-' . t('Time'), @@ -411,18 +424,21 @@ /** * Theme the output of the export form. */ -function theme_webform_results_download_form($form) { +function theme_webform_results_download_form($variables) { drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); - return drupal_render($form); + $form = $variables['form']; + + return drupal_render_children($form); } /** * Theme the output of the select list format radio buttons. */ -function theme_webform_results_download_select_format($element) { +function theme_webform_results_download_select_format($variables) { drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); + $element = $variables['element']; $output = ''; // Build an example table for the separate option. @@ -433,7 +449,8 @@ array('', 'X', 'X'), ); - $element['separate']['#description'] = theme('table', $header, $rows); + $element['separate']['#attributes']['class'] = array(); + $element['separate']['#description'] = theme('table', array('header' => $header, 'rows' => $rows)); $element['separate']['#description'] .= t('Separate options are more suitable for building reports, graphs, and statistics in a spreadsheet application.'); $output .= drupal_render($element['separate']); @@ -445,13 +462,11 @@ array('Option B,Option C'), ); - $element['compact']['#description'] = theme('table', $header, $rows); + $element['compact']['#attributes']['class'] = array(); + $element['compact']['#description'] = theme('table', array('header' => $header, 'rows' => $rows)); $element['compact']['#description'] .= t('Compact options are more suitable for importing data into other systems.'); $output .= drupal_render($element['compact']); - $element['#type'] = 'markup'; - $element['#value'] = $output; - return $output; } @@ -645,7 +660,7 @@ } } - return theme('webform_results_analysis', $node, $data, $sids, $analysis_component); + return theme('webform_results_analysis', array('node' => $node, 'data' => $data, 'sids' => $sids, 'component' => $analysis_component)); } /** @@ -653,13 +668,17 @@ * * @see webform_results_analysis() */ -function theme_webform_results_analysis($node, $data, $sids = array(), $analysis_component = NULL) { +function theme_webform_results_analysis($variables) { + $node = $variables['node']; + $data = $variables['data']; + $sids = $variables['sids']; + $analysis_component = $variables['component']; $rows = array(); $question_number = 0; $single = isset($analysis_component); - $headers = array( + $header = array( $single ? $analysis_component['name'] : t('Q'), array('data' => $single ? ' ' : t('responses'), 'colspan' => '10') ); @@ -681,5 +700,5 @@ $rows[] = array(array('data' => t('There are no submissions for this form. View this form.', array('!url' => url('node/' . $node->nid))), 'colspan' => 20)); } - return theme('table', $headers, $rows); + return theme('table', array('header' => $header, 'rows' => $rows)); } Index: includes/webform.form_builder.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.form_builder.inc,v retrieving revision 1.6 diff -u -r1.6 webform.form_builder.inc --- includes/webform.form_builder.inc 3 Mar 2010 02:51:37 -0000 1.6 +++ includes/webform.form_builder.inc 8 Mar 2010 00:55:55 -0000 @@ -25,9 +25,7 @@ * The actual Form Builder interface is displayed as part of the * webform_form_builder_components() function. */ -function webform_form_builder_save_form(&$form_state, $nid) { - $form = array(); - +function webform_form_builder_save_form($form, &$form_state, $nid) { $form['nid'] = array( '#type' => 'value', '#value' => $nid, @@ -176,8 +174,9 @@ $nid = $form_builder_id; $node = node_load($nid); // Get the unfiltered version of the client form. + $form = array(); $form_state = array(); - $form = webform_client_form($form_state, $node, array(), TRUE, FALSE, FALSE); + $form = webform_client_form($form, $form_state, $node, array(), TRUE, FALSE, FALSE); webform_form_builder_load_process($form['submitted'], $node); return $form['submitted']; } Index: includes/webform.submissions.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.submissions.inc,v retrieving revision 1.19 diff -u -r1.19 webform.submissions.inc --- includes/webform.submissions.inc 3 Mar 2010 02:51:37 -0000 1.19 +++ includes/webform.submissions.inc 8 Mar 2010 00:55:56 -0000 @@ -44,16 +44,28 @@ } // Update the main submission info. - $result = db_query("UPDATE {webform_submissions} SET uid = %d, submitted = %d, remote_addr = '%s', is_draft = %d WHERE sid = %d", $submission->uid, $submission->submitted, $submission->remote_addr, $submission->is_draft, $submission->sid); + db_update('webform_submissions') + ->fields(array( + 'uid' => $submission->uid, + 'submitted' => $submission->submitted, + 'remote_addr' => $submission->remote_addr, + 'is_draft' => $submission->is_draft, + )) + ->condition('sid', $submission->sid) + ->execute(); // If is draft, only delete data for components submitted, to // preserve any data from form pages not visited in this submission. if ($submission->is_draft) { - $submitted_cids = array_keys($submission->data); - db_query("DELETE FROM {webform_submitted_data} WHERE sid = %d AND cid IN (" . implode(', ', $submitted_cids) . ")", $submission->sid); + db_delete('webform_submitted_data') + ->condition('sid', $submission->sid) + ->condition('cid', array_keys($submission->data), 'IN') + ->execute(); } else { - db_query("DELETE FROM {webform_submitted_data} WHERE sid = %d", $submission->sid); + db_delete('webform_submitted_data') + ->condition('sid', $submission->sid) + ->execute(); } // Then re-add submission data to the database. @@ -74,14 +86,29 @@ $function($node, $submission); } - $result = db_query("INSERT INTO {webform_submissions} (nid, uid, submitted, remote_addr, is_draft) VALUES (%d, %d, %d, '%s', %d)", $node->nid, $submission->uid, $submission->submitted, $submission->remote_addr, $submission->is_draft); - $submission->sid = db_last_insert_id('webform_submissions', 'sid'); + $submission->sid = db_insert('webform_submissions') + ->fields(array( + 'nid' => $node->nid, + 'uid' => $submission->uid, + 'submitted' => $submission->submitted, + 'remote_addr' => $submission->remote_addr, + 'is_draft' => $submission->is_draft, + )) + ->execute(); $is_new = TRUE; } foreach ($submission->data as $cid => $values) { foreach ($values['value'] as $delta => $value) { - db_query("INSERT INTO {webform_submitted_data} (nid, sid, cid, no, data) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $submission->sid, $cid, $delta, $value); + db_insert('webform_submitted_data') + ->fields(array( + 'nid' => $node->nid, + 'sid' => $submission->sid, + 'cid' => $cid, + 'no' => $delta, + 'data' => $value + )) + ->execute(); } } @@ -114,8 +141,14 @@ unset($_SESSION['webform_submission'][$submission->sid]); } - db_query('DELETE FROM {webform_submitted_data} WHERE nid = %d AND sid = %d', $node->nid, $submission->sid); - db_query('DELETE FROM {webform_submissions} WHERE nid = %d AND sid = %d', $node->nid, $submission->sid); + db_delete('webform_submitted_data') + ->condition('nid', $node->nid) + ->condition('sid', $submission->sid) + ->execute(); + db_delete('webform_submissions') + ->condition('nid', $node->nid) + ->condition('sid', $submission->sid) + ->execute(); module_invoke_all('webform_submission_delete', $node, $submission); } @@ -123,6 +156,8 @@ /** * Confirm form to delete a single form submission. * + * @param $form + * The new form array. * @param $form_state * The current form state. * @param $node @@ -130,7 +165,7 @@ * @param $submission * The submission to be deleted (from webform_submitted_data). */ -function webform_submission_delete_form($form_state, $node, $submission) { +function webform_submission_delete_form($form, $form_state, $node, $submission) { webform_set_breadcrumb($node, $submission); $form = array(); @@ -190,8 +225,8 @@ // Add navigation for administrators. if (user_access('access all webform results') || (user_access('access own webform results') && $user->uid == $node->uid)) { - $navigation = ($mode != 'pdf') ? theme('webform_submission_navigation', $node, $submission, $mode) : NULL; - $information = theme('webform_submission_information', $node, $submission); + $navigation = ($mode != 'pdf') ? theme('webform_submission_navigation', array('node' => $node, 'submission' => $submission, 'mode' => $mode)) : NULL; + $information = theme('webform_submission_information', array('node' => $node, 'submission' => $submission)); } else { $navigation = NULL; @@ -203,7 +238,7 @@ webform_disable_page_cache(); } - return theme('webform_submission_page', $node, $submission, $output, $navigation, $information); + return theme('webform_submission_page', array('node' => $node, 'submission' => $submission, 'submission_content' => $output, 'submission_navigation' => $navigation, 'submission_information' => $information)); } /** @@ -253,40 +288,32 @@ } // Build the list of SIDs that need to be retrieved. else { - $arguments = array_values($filters); - $where = array(); + $pager_query = db_select('webform_submissions')->fields('webform_submissions', array('sid')); foreach ($filters as $column => $value) { - $where[] = $column . ' = ' . (is_numeric($value) ? '%d' : "'%s'"); + $pager_query->condition($column, $value); } if (isset($filters['uid']) && $filters['uid'] === 0) { $anonymous_sids = array_keys($_SESSION['webform_submission']); if (count($anonymous_sids)) { - $placeholders = array_fill(0, count($anonymous_sids), "%d"); - $where[] = 'sid IN (' . implode(',', $placeholders) . ')'; - $arguments = array_merge($arguments, $anonymous_sids); + $pager_query->condition('sid', $anonymous_sids, 'IN'); } } - $where_clause = implode(' AND ', $where); - $pager_query = 'SELECT sid FROM {webform_submissions} WHERE ' . $where_clause; - if (is_array($header)) { - $pager_query .= tablesort_sql($header); + $pager_query->extend('TableSort')->orderByHeader($header); } else { - $pager_query .= ' ORDER BY sid ASC'; + $pager_query->orderBy('sid', 'ASC'); } if ($pager_count) { - $result = pager_query($pager_query, $pager_count, 0, NULL, $arguments); - } - else { - $result = db_query($pager_query, $arguments); + $pager_query->extend('PagerDefault')->limit($pager_count); } + $result = $pager_query->execute(); $sids = array(); - while ($row = db_fetch_object($result)) { + foreach ($result as $row) { $sids[] = $row->sid; $submissions[$row->sid] = FALSE; } @@ -298,18 +325,22 @@ } // Query the required submission data. - $query = 'SELECT s.*, sd.cid, sd.no, sd.data, u.name, u.mail, u.status ' . - 'FROM {webform_submissions} s ' . - 'LEFT JOIN {webform_submitted_data} sd ON sd.sid = s.sid ' . - 'LEFT JOIN {users} u ON u.uid = s.uid ' . - 'WHERE s.sid IN (' . implode($sids, ',') . ') ' . - 'ORDER BY sd.sid ASC, sd.cid ASC, sd.no ASC'; - - $result = db_query($query); + $query = db_select('webform_submissions', 's'); + $query->leftJoin('webform_submitted_data', 'sd', 'sd.sid = s.sid'); + $query->leftJoin('users', 'u', 'u.uid = s.uid'); + $query + ->fields('s') + ->fields('sd') + ->fields('u', array('name')) + ->condition('s.sid', $sids, 'IN') + ->orderBy('sd.sid', 'ASC') + ->orderBy('sd.cid', 'ASC') + ->orderBy('sd.no', 'ASC'); + $result = $query->execute(); // Convert the queried rows into submissions. - $previous = array(); - while ($row = db_fetch_object($result)) { + $previous = 0; + foreach ($result as $row) { if ($row->sid != $previous) { $submissions[$row->sid] = new stdClass(); $submissions[$row->sid]->sid = $row->sid; @@ -318,7 +349,6 @@ $submissions[$row->sid]->remote_addr = $row->remote_addr; $submissions[$row->sid]->uid = $row->uid; $submissions[$row->sid]->name = $row->name; - $submissions[$row->sid]->status = $row->status; $submissions[$row->sid]->is_draft = $row->is_draft; } $submissions[$row->sid]->data[$row->cid]['value'][$row->no] = $row->data; @@ -347,20 +377,19 @@ static $counts; if (!isset($counts[$nid][$uid]) || $reset) { - $query = 'SELECT count(*) FROM {webform_submissions} WHERE nid = %d'; + $query = db_select('webform_submissions') + ->countQuery() + ->condition('nid', $nid); $arguments = array($nid); if ($uid !== NULL) { - $query .= ' AND uid = %d'; - $arguments[] = $uid; + $query->condition('uid', $uid); } if ($uid === 0) { $submissions = isset($_SESSION['webform_submission']) ? $_SESSION['webform_submission'] : array(); - $placeholders = count($submissions) ? array_fill(0, count($submissions), "%d") : array(); - $query .= count($submissions) ? ' AND sid IN (' . implode(',', $placeholders) . ')' : ' AND sid = 0'; - $arguments = array_merge($arguments, array_keys($submissions)); + $query->condition('sid', $submissions, 'IN'); } - $counts[$nid][$uid] = db_result(db_query($query, $arguments)); + $counts[$nid][$uid] = $query->execute()->fetchField(); } return $counts[$nid][$uid]; } @@ -418,13 +447,24 @@ } // Retrieve submission data for this IP address or username from the database. - $query = 'SELECT count(*) ' . - 'FROM {webform_submissions} ' . - "WHERE (( 0 = %d AND remote_addr = '%s') OR (uid > 0 AND uid = %d)) " . - 'AND submitted > %d AND nid = %d AND is_draft = 0'; + $query = db_select('webform_submissions') + ->countQuery() + ->condition('nid', $node->nid) + ->condition('is_draft', 0); + + if ($node->webform['submit_interval'] != -1) { + $query->condition('submitted', REQUEST_TIME - $node->webform['submit_interval'], '>'); + } + + if ($user->uid) { + $query->condition('uid', $user->uid); + } + else { + $query->condition('remote_addr', ip_address); + } // Fetch all the entries from the database within the submit interval with this username and IP. - $num_submissions_database = db_result(db_query($query, $user->uid, ip_address(), $user->uid, ($node->webform['submit_interval'] != -1) ? (time() - $node->webform['submit_interval']) : $node->webform['submit_interval'], $node->nid)); + $num_submissions_database = $query->execute()->fetchField(); // Double check the submission history from the users machine using cookies. $num_submissions_cookie = 0; @@ -433,7 +473,7 @@ if (isset($_COOKIE[$cookie_name]) && is_array($_COOKIE[$cookie_name])) { foreach ($_COOKIE[$cookie_name] as $key => $timestamp) { - if ($node->webform['submit_interval'] != -1 && $timestamp <= time() - $node->webform['submit_interval']) { + if ($node->webform['submit_interval'] != -1 && $timestamp <= REQUEST_TIME - $node->webform['submit_interval']) { // Remove the cookie if past the required time interval. setcookie($cookie_name . '[' . $key . ']', '', 0); } @@ -460,8 +500,19 @@ */ function template_preprocess_webform_submission_navigation(&$vars) { $start_path = ($vars['mode'] == 'print') ? 'print/' : 'node/'; - $vars['previous'] = db_result(db_query('SELECT MAX(sid) FROM {webform_submissions} WHERE nid = %d AND sid < %d', array($vars['node']->nid, $vars['submission']->sid))); - $vars['next'] = db_result(db_query('SELECT MIN(sid) FROM {webform_submissions} WHERE nid = %d AND sid > %d', array($vars['node']->nid, $vars['submission']->sid))); + + $previous_query = db_select('webform_submissions') + ->condition('nid', $vars['node']->nid) + ->condition('sid', $vars['submission']->sid, '<'); + $previous_query->addExpression('MAX(sid)'); + + $next_query = db_select('webform_submissions') + ->condition('nid', $vars['node']->nid) + ->condition('sid', $vars['submission']->sid, '>'); + $next_query->addExpression('MIN(sid)'); + + $vars['previous'] = $previous_query->execute()->fetchField(); + $vars['next'] = $next_query->execute()->fetchField(); $vars['previous_url'] = $start_path . $vars['node']->nid . '/submission/' . $vars['previous'] . ($vars['mode'] == 'form' ? '/edit' : ''); $vars['next_url'] = $start_path . $vars['node']->nid . '/submission/' . $vars['next'] . ($vars['mode'] == 'form' ? '/edit' : ''); } @@ -470,5 +521,5 @@ * Preprocess function for webform-submission-navigation.tpl.php */ function template_preprocess_webform_submission_information(&$vars) { - $vars['account'] = user_load(array('uid' => $vars['submission']->uid)); + $vars['account'] = user_load($vars['submission']->uid); } Index: includes/webform.components.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.components.inc,v retrieving revision 1.26 diff -u -r1.26 webform.components.inc --- includes/webform.components.inc 3 Mar 2010 02:51:37 -0000 1.26 +++ includes/webform.components.inc 8 Mar 2010 00:55:55 -0000 @@ -25,7 +25,12 @@ $output = drupal_get_form('webform_components_form', $node); } - return theme('webform_components_page', $node, $mode, $output); + return array( + '#theme' => 'webform_components_page', + '#node' => $node, + '#mode' => $mode, + '#form' => $output, + ); } /** @@ -34,13 +39,12 @@ * This theming provides a way to toggle between the editing modes if Form * Builder module is available. */ -function theme_webform_components_page($node, $mode, $form) { +function theme_webform_components_page($variables) { + $node = $variables['node']; + $mode = $variables['node']; + $form = $variables['form']; $output = ''; - // Add CSS and JS. Don't preprocess because these files are used rarely. - drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); - drupal_add_js(drupal_get_path('module', 'webform') . '/webform.js', 'module', 'header', FALSE, TRUE, FALSE); - if (module_exists('form_builder')) { $output .= '
'; $output .= '' . t('Display mode') . ': '; @@ -57,7 +61,7 @@ $output .= '
'; } - $output .= $form; + $output .= drupal_render($form); return $output; } @@ -65,7 +69,7 @@ /** * The table-based listing of all components for this webform. */ -function webform_components_form($form_state, $node) { +function webform_components_form($form, $form_state, $node) { $form = array( '#tree' => TRUE, '#node' => $node, @@ -153,26 +157,31 @@ * @return * Formatted HTML form, ready for display. */ -function theme_webform_components_form($form) { - // Add CSS to display submission info. Don't preprocess because this CSS file is used rarely. - drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); - drupal_add_js(drupal_get_path('module', 'webform') . '/webform.js', 'module', 'header', FALSE, TRUE, FALSE); +function theme_webform_components_form($variables) { + $form = $variables['form']; + + $path = drupal_get_path('module', 'webform'); + $form['components']['#attached'] = array( + 'css' => array($path . '/webform.css' => array('preprocess' => FALSE, 'weight' => CSS_DEFAULT + 1)), + 'js' => array($path . '/webform.js' => array('preprocess' => FALSE)), + ); + // TODO: Attach these. See http://drupal.org/node/732022. drupal_add_tabledrag('webform-components', 'order', 'sibling', 'webform-weight'); drupal_add_tabledrag('webform-components', 'match', 'parent', 'webform-pid', 'webform-pid', 'webform-cid'); $node = $form['#node']; - $headers = array(t('Name'), t('Type'), t('Value'), t('Mandatory'), t('Weight'), array('data' => t('Operations'), 'colspan' => 3)); + $header = array(t('Name'), t('Type'), t('Value'), t('Mandatory'), t('Weight'), array('data' => t('Operations'), 'colspan' => 3)); $rows = array(); // Add a row containing form elements for a new item. unset($form['add']['name']['#title'], $form['add_type']['#description']); $form['add']['name']['#value'] = t('New component name'); - $form['add']['name']['#attributes']['class'] = 'webform-default-value'; - $form['add']['cid']['#attributes']['class'] = 'webform-cid'; - $form['add']['pid']['#attributes']['class'] = 'webform-pid'; - $form['add']['weight']['#attributes']['class'] = 'webform-weight'; + $form['add']['name']['#attributes']['class'] = array('webform-default-value'); + $form['add']['cid']['#attributes']['class'] = array('webform-cid'); + $form['add']['pid']['#attributes']['class'] = array('webform-pid'); + $form['add']['weight']['#attributes']['class'] = array('webform-weight'); $row_data = array( drupal_render($form['add']['name']), drupal_render($form['add']['type']), @@ -181,7 +190,7 @@ drupal_render($form['add']['cid']) . drupal_render($form['add']['pid']) . drupal_render($form['add']['weight']), array('colspan' => 3, 'data' => drupal_render($form['add']['add'])), ); - $add_form = array('data' => $row_data, 'class' => 'draggable webform-add-form'); + $add_form = array('data' => $row_data, 'class' => array('draggable', 'webform-add-form')); $form_rendered = FALSE; if (!empty($node->webform['components'])) { @@ -204,9 +213,9 @@ unset($form['components'][$cid]['weight']['#title']); // Add special classes for weight and parent fields. - $form['components'][$cid]['cid']['#attributes']['class'] = 'webform-cid'; - $form['components'][$cid]['pid']['#attributes']['class'] = 'webform-pid'; - $form['components'][$cid]['weight']['#attributes']['class'] = 'webform-weight'; + $form['components'][$cid]['cid']['#attributes']['class'] = array('webform-cid'); + $form['components'][$cid]['pid']['#attributes']['class'] = array('webform-pid'); + $form['components'][$cid]['weight']['#attributes']['class'] = array('webform-weight'); // Build indentation for this row. $indents = ''; @@ -225,13 +234,14 @@ l(t('Clone'), 'node/' . $node->nid . '/webform/components/' . $cid . '/clone', array('query' => drupal_get_destination())), l(t('Delete'), 'node/' . $node->nid . '/webform/components/' . $cid . '/delete', array('query' => drupal_get_destination())), ); - $row_class = 'draggable'; + $row_class = array('draggable'); if ($component['type'] != 'fieldset' && $component['type'] != 'pagebreak') { - $row_class .= ' tabledrag-leaf'; + $row_class[] = 'tabledrag-leaf'; } if ($component['type'] == 'pagebreak') { - $row_class .= ' tabledrag-root webform-pagebreak'; - $row_data[0] = array('class' => 'webform-pagebreak', 'data' => $row_data[0]); + $row_class[] = 'tabledrag-root'; + $row_class[] = 'webform-pagebreak'; + $row_data[0] = array('class' => array('webform-pagebreak'), 'data' => $row_data[0]); } $rows[] = array('data' => $row_data, 'class' => $row_class); if (isset($component['children']) && is_array($component['children'])) { @@ -261,8 +271,8 @@ } $output = ''; - $output .= theme('table', $headers, $rows, array('id' => 'webform-components')); - $output .= drupal_render($form); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'webform-components'))); + $output .= drupal_render_children($form); return $output; } @@ -294,7 +304,7 @@ } elseif (isset($_POST['op']) && $_POST['op'] == t('Add')) { $component = $form_state['values']['add']; - $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], 'name=' . urlencode($component['name']) . ' &mandatory=' . $component['mandatory'] . '&pid=' . $component['pid'] . '&weight=' . $component['weight']); + $form_state['redirect'] = array('node/' . $node->nid . '/webform/components/new/' . $component['type'], array('query' => array('name' => $component['name'], 'mandatory' => $component['mandatory'], 'pid' => $component['pid'], 'weight' => $component['weight']))); } else { drupal_set_message(t('The component positions and mandatory values have been updated.')); @@ -306,8 +316,8 @@ } } -function webform_component_edit_form(&$form_state, $node, $component, $clone = FALSE) { - drupal_set_title(t('Edit component: @name (@type)', array('@name' => $component['name'], '@type' => t($component['type'])))); +function webform_component_edit_form($form, $form_state, $node, $component, $clone = FALSE) { + drupal_set_title(t('Edit component: @name (@type)', array('@name' => $component['name'], '@type' => t($component['type']))), PASS_THROUGH); drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); // Print the correct field type specification. @@ -390,7 +400,7 @@ '#collapsed' => TRUE, '#tree' => FALSE, '#weight' => 20, - '#attributes' => array('class' => 'webform-position'), + '#attributes' => array('class' => array('webform-position')), ); if (variable_get('webform_enable_fieldset', TRUE) && is_array($node->webform['components'])) { @@ -578,10 +588,10 @@ // the updated webform is visible to anonymous users. cache_clear_all(); - $form_state['redirect'] = array('node/' . $form_state['values']['nid'] . '/webform/components', isset($cid) ? 'cid=' . $cid : ''); + $form_state['redirect'] = array('node/' . $form_state['values']['nid'] . '/webform/components', isset($cid) ? array('query' => array('cid' => $cid)) : array()); } -function webform_component_delete_form($form_state, $node, $component) { +function webform_component_delete_form($form, $form_state, $node, $component) { $cid = $component['cid']; $form = array(); @@ -625,12 +635,30 @@ $function($component); } - db_lock_table('webform_component'); - $component['cid'] = isset($component['cid']) ? $component['cid'] : db_result(db_query('SELECT MAX(cid) FROM {webform_component} WHERE nid = %d', $component['nid'])) + 1; $component['value'] = isset($component['value']) ? $component['value'] : NULL; $component['mandatory'] = isset($component['mandatory']) ? $component['mandatory'] : 0; - db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d)", $component['nid'], $component['cid'], $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight']); - db_unlock_tables(); + + // TODO: This is not race-condition safe. Switch to using transactions? + if (!isset($component['cid'])) { + $next_id_query = db_select('webform_component')->condition('nid', $component['nid']); + $next_id_query->addExpression('MAX(cid) + 1', 'cid'); + $component['cid'] = $next_id_query->execute()->fetchField(); + } + + $query = db_insert('webform_component') + ->fields(array( + 'nid' => $component['nid'], + 'cid' => $component['cid'], + 'pid' => $component['pid'], + 'form_key' => $component['form_key'], + 'name' => $component['name'], + 'type' => $component['type'], + 'value' => $component['value'], + 'extra' => serialize($component['extra']), + 'mandatory' => $component['mandatory'], + 'weight' => $component['weight'], + )) + ->execute(); // Post-insert actions. module_invoke_all('webform_component_insert', $component); @@ -654,12 +682,23 @@ $component['value'] = isset($component['value']) ? $component['value'] : NULL; $component['mandatory'] = isset($component['mandatory']) ? $component['mandatory'] : 0; - $success = db_query("UPDATE {webform_component} SET pid = %d, form_key = '%s', name = '%s', type = '%s', value = '%s', extra = '%s', mandatory = %d, weight = %d WHERE nid = %d AND cid = %d", $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight'], $component['nid'], $component['cid']); + db_update('webform_component') + ->fields(array( + 'pid' => $component['pid'], + 'form_key' => $component['form_key'], + 'name' => $component['name'], + 'type' => $component['type'], + 'value' => $component['value'], + 'extra' => serialize($component['extra']), + 'mandatory' => $component['mandatory'], + 'weight' => $component['weight'] + )) + ->condition('nid', $component['nid']) + ->condition('cid', $component['cid']) + ->execute(); // Post-update actions. module_invoke_all('webform_component_update', $component); - - return $success; } function webform_component_delete($node, $component) { @@ -679,12 +718,21 @@ } // Remove database entries. - db_query('DELETE FROM {webform_component} WHERE nid = %d AND cid = %d', $node->nid, $component['cid']); - db_query('DELETE FROM {webform_submitted_data} WHERE nid = %d AND cid = %d', $node->nid, $component['cid']); + db_delete('webform_component') + ->condition('nid', $node->nid) + ->condition('cid', $component['cid']) + ->execute(); + db_delete('webform_submitted_data') + ->condition('nid', $node->nid) + ->condition('cid', $component['cid']) + ->execute(); // Delete all elements under this element. - $result = db_query('SELECT cid FROM {webform_component} WHERE nid = %d AND pid = %d', $node->nid, $component['cid']); - while ($row = db_fetch_object($result)) { + $result = db_select('webform_component') + ->condition('nid', $node->nid) + ->condition('cid', $component['cid']) + ->execute(); + foreach ($result as $row) { $component = $node->webform['components'][$row->cid]; webform_component_delete($node, $component); } @@ -808,6 +856,7 @@ // Set value to NULL so that Drupal doesn't output "Array" as the markup. $element['#value'] = NULL; $element['#type'] = 'markup'; + $element['#theme_wrappers'] = array(); $element['#theme'] = 'webform_component_select'; return $element; @@ -816,24 +865,25 @@ /** * Theme the contents of a Webform component select element. */ -function theme_webform_component_select($element) { +function theme_webform_component_select($variables) { + $element = $variables['element']; drupal_add_js('misc/tableselect.js'); drupal_add_js(drupal_get_path('module', 'webform') . '/webform.js', 'module', 'header', FALSE, TRUE, FALSE); $rows = array(); $header = array(); - $header = array(array('class' => 'select-all', 'data' => ' ' . t('Include all components'))); + $header = array(array('class' => array('select-all'), 'data' => ' ' . t('Include all components'))); foreach (element_children($element) as $key) { $rows[] = array( - theme('indentation', $element[$key]['#indent']) . drupal_render($element[$key]), + theme('indentation', array('size' => $element[$key]['#indent'])) . drupal_render($element[$key]), ); } - $element['#collapsible'] = TRUE; - $element['#collapsed'] = TRUE; - $element['#attributes']['class'] = 'webform-component-select-table'; - $element['#children'] = theme('table', $header, $rows);; - return theme('fieldset', $element); + $element['#type'] = 'fieldset'; + $element['#attributes']['class'] = array('webform-component-select-table', 'collapsible', 'collapsed'); + $element['#children'] = theme('table', array('header' => $header, 'rows' => $rows)); + + return theme('fieldset', array('element' => $element)); } /** @@ -878,7 +928,15 @@ function webform_validate_unique($element, $form_state) { $nid = $form_state['values']['details']['nid']; $sid = $form_state['values']['details']['sid']; - $count = db_result(db_query("SELECT count(*) FROM {webform_submitted_data} WHERE nid = %d AND cid = %d AND sid <> %d AND LOWER(data) = '%s'", $nid, $element['#webform_component']['cid'], $sid, $element['#value'])); + $count = db_select('webform_submitted_data') + ->fields('webform_submitted_data', 'sid') + ->condition('nid', $nid) + ->condition('cid', $element['#webform_component']['cid']) + ->condition('sid', $sid, '<>') + ->condition('data', $element['#value']) + ->range(0, 1) // More efficient than using countQuery() for data checks. + ->execute() + ->fetchField(); if ($count) { form_error($element, t('The value %value has already been submitted once for the %title field. You may have already submitted this form, or you need to use a different value.', array('%value' => $element['#value'], '%title' => $element['#title']))); } Index: includes/webform.emails.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.emails.inc,v retrieving revision 1.10 diff -u -r1.10 webform.emails.inc --- includes/webform.emails.inc 3 Mar 2010 02:51:37 -0000 1.10 +++ includes/webform.emails.inc 8 Mar 2010 00:55:55 -0000 @@ -11,10 +11,15 @@ /** * Overview form of all components for this webform. */ -function webform_emails_form($form_state, $node) { +function webform_emails_form($form, $form_state, $node) { + $path = drupal_get_path('module', 'webform'); $form = array( '#tree' => TRUE, '#node' => $node, + '#attached' => array( + 'css' => array($path . '/webform.css' => array('preprocess' => FALSE, 'weight' => CSS_DEFAULT + 1)), + 'js' => array($path . '/webform.js' => array('preprocess' => FALSE)), + ), 'components' => array(), ); @@ -83,14 +88,11 @@ * @return * Formatted HTML form, ready for display. */ -function theme_webform_emails_form($form) { - // Add CSS to display submission info. Don't preprocess because this CSS file is used rarely. - drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); - drupal_add_js(drupal_get_path('module', 'webform') . '/webform.js', 'module', 'header', FALSE, TRUE, FALSE); - +function theme_webform_emails_form($variables) { + $form = $variables['form']; $node = $form['#node']; - $headers = array(t('E-mail to'), t('Subject'), t('From'), array('data' => t('Operations'), 'colspan' => 2)); + $header = array(t('E-mail to'), t('Subject'), t('From'), array('data' => t('Operations'), 'colspan' => 2)); $rows = array(); if (!empty($form['emails'])) { @@ -114,25 +116,27 @@ array('colspan' => 3, 'data' => drupal_render($form['add'])), array('colspan' => 2, 'data' => drupal_render($form['add_button'])), ); - $rows[] = array('data' => $row_data, 'class' => 'webform-add-form'); + $rows[] = array('data' => $row_data, 'class' => array('webform-add-form')); $output = ''; - $output .= theme('table', $headers, $rows, array('id' => 'webform-emails')); - $output .= drupal_render($form); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'webform-emails'))); + $output .= drupal_render_children($form); return $output; } /** * Theme the add new e-mail settings form on the node/x/webform/emails page. */ -function theme_webform_email_add_form($form) { +function theme_webform_email_add_form($variables) { + $form = $variables['form']; + // Add a default value to the custom e-mail textfield. $form['email_custom']['#value'] = t('email@example.com'); - $form['email_custom']['#attributes']['class'] = 'webform-set-active webform-default-value'; + $form['email_custom']['#attributes']['class'] = array('webform-set-active', 'webform-default-value'); $form['email_option']['custom']['#title'] = $form['email_option']['custom']['#title'] . ': ' . drupal_render($form['email_custom']); // Render the component value. - $form['email_component']['#attributes']['class'] = 'webform-set-active'; + $form['email_component']['#attributes']['class'] = array('webform-set-active'); $form['email_option']['component']['#title'] = $form['email_option']['component']['#title'] . ': ' . drupal_render($form['email_component']); // For spacing consistency, every option is wrapped in container-inline. @@ -141,7 +145,7 @@ $form['email_option'][$option]['#suffix'] = ''; } - return drupal_render($form); + return drupal_render_children($form); } /** @@ -154,15 +158,20 @@ else { $email = $form_state['values']['email_component']; } - $form_state['redirect'] = array('node/' . $form['#node']->nid . '/webform/emails/new', 'option=' . urlencode($form_state['values']['email_option']) . '&email=' . urlencode(trim($email))); + $form_state['redirect'] = array('node/' . $form['#node']->nid . '/webform/emails/new', array('option' => $form_state['values']['email_option'], 'email' => trim($email))); } /** * Form for configuring an e-mail setting and template. */ -function webform_email_edit_form($form_state, $node, $email = array()) { +function webform_email_edit_form($form, $form_state, $node, $email = array()) { + $path = drupal_get_path('module', 'webform'); $form = array( '#tree' => TRUE, + '#attached' => array( + 'css' => array($path . '/webform.css' => array('preprocess' => FALSE, 'weight' => CSS_DEFAULT + 1)), + 'js' => array($path . '/webform.js' => array('preprocess' => FALSE)), + ) ); $form['node'] = array( '#type' => 'value', @@ -245,12 +254,12 @@ '#attributes' => array('id' => 'webform-template-fieldset'), ); - $default_template = theme(array('webform_mail_' . $node->nid, 'webform_mail', 'webform_mail_message'), $node, NULL, 'default'); + $default_template = theme(array('webform_mail_' . $node->nid, 'webform_mail', 'webform_mail_message'), array('node' => $node, 'cid' => 'default')); $template = $email['template'] == 'default' ? $default_template : $email['template']; $form['template']['template'] = array( '#type' => 'textarea', '#rows' => max(10, min(20, count(explode("\n", $template)))), - '#description' => theme('webform_token_help', $node), + '#description' => theme('webform_token_help'), '#default_value' => $template, ); @@ -298,14 +307,13 @@ /** * Theme the Webform mail settings section of the node form. */ -function theme_webform_email_edit_form($form) { - drupal_add_css(drupal_get_path('module', 'webform') . '/webform.css', 'theme', 'all', FALSE); - drupal_add_js(drupal_get_path('module', 'webform') . '/webform.js', 'module', 'header', FALSE, TRUE, FALSE); +function theme_webform_email_edit_form($variables) { + $form = $variables['form']; // Loop through fields, rendering them into radio button options. foreach (array('email', 'subject', 'from_address', 'from_name') as $field) { foreach (array('custom' => t('Custom'), 'component' => t('Component')) as $option => $title) { - $form[$field . '_' . $option]['#attributes']['class'] = 'webform-set-active'; + $form[$field . '_' . $option]['#attributes']['class'] = array('webform-set-active'); $form[$field . '_option'][$option]['#title'] = $title . ': ' . drupal_render($form[$field . '_' . $option]); } // For spacing consistency, every option is wrapped in container-inline. @@ -315,7 +323,7 @@ } // Wrap the default option in a placeholder tag.. if (isset($form[$field . '_option']['#options']['default'])) { - $form[$field . '_option']['default']['#title'] = t('Default') . ': ' . theme('placeholder', $form[$field . '_option']['default']['#title']); + $form[$field . '_option']['default']['#title'] = t('Default') . ': ' . drupal_placeholder(array('text' => $form[$field . '_option']['default']['#title'])); } } @@ -329,11 +337,13 @@ '#weight' => 10, '#children' => $details, '#collapsible' => FALSE, + '#parents' => array('details'), + '#attributes' => array(), ); $form['template']['template']['#description'] .= drupal_render($form['template']['components']); - return drupal_render($form); + return drupal_render_children($form); } /** @@ -420,10 +430,9 @@ /** * Form for deleting an e-mail setting. */ -function webform_email_delete_form($form_state, $node, $email) { +function webform_email_delete_form($form, $form_state, $node, $email) { $eid = $email['eid']; - $form = array(); $form['node'] = array( '#type' => 'value', '#value' => $node, @@ -460,11 +469,17 @@ * An array of settings for sending an e-mail. */ function webform_email_insert($email) { - db_lock_table('webform_emails'); - $email['eid'] = isset($email['eid']) ? $email['eid'] : db_result(db_query('SELECT MAX(eid) FROM {webform_emails} WHERE nid = %d', $email['nid'])) + 1; - db_query("INSERT INTO {webform_emails} (nid, eid, email, subject, from_name, from_address, template, excluded_components) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", $email['nid'], $email['eid'], $email['email'], $email['subject'], $email['from_name'], $email['from_address'], $email['template'], implode(',', $email['excluded_components'])); - db_unlock_tables(); - return $email['eid']; + // TODO: This is not race-condition safe. Switch to using transactions? + if (!isset($email['eid'])) { + $next_id_query = db_select('webform_emails')->condition('nid', $email['nid']); + $email->addExpression('MAX(cid) + 1', 'eid'); + $component['eid'] = $next_id_query->execute()->fetchField(); + } + + $email['excluded_components'] = implode(',', $email['excluded_components']); + $success = drupal_write_record($email); + + return $success ? $email['eid'] : FALSE; } /** @@ -475,12 +490,16 @@ * other fields from the e-mail form. */ function webform_email_update($email) { - return db_query("UPDATE {webform_emails} SET email = '%s', subject = '%s', from_name = '%s', from_address = '%s', template = '%s', excluded_components = '%s' WHERE nid = %d AND eid = %d", $email['email'], $email['subject'], $email['from_name'], $email['from_address'], $email['template'], implode(',', $email['excluded_components']), $email['nid'], $email['eid']); + $email['excluded_components'] = implode(',', $email['excluded_components']); + return drupal_write_record($email); } /** * Delete an e-mail setting. */ function webform_email_delete($node, $email) { - db_query('DELETE FROM {webform_emails} WHERE nid = %d AND eid = %d', $node->nid, $email['eid']); + db_delete('webform_emails') + ->condition('nid', $node->nid) + ->condition('eid', $email['eid']) + ->execute(); } Index: includes/webform.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.pages.inc,v retrieving revision 1.10 diff -u -r1.10 webform.pages.inc --- includes/webform.pages.inc 11 Feb 2010 22:05:27 -0000 1.10 +++ includes/webform.pages.inc 8 Mar 2010 00:55:55 -0000 @@ -10,7 +10,7 @@ /** * Main configuration form for editing a webform node. */ -function webform_configure_form(&$form_state, $node) { +function webform_configure_form($form, &$form_state, $node) { $form = array(); $form['nid'] = array( @@ -27,17 +27,17 @@ '#weight' => -4, ); - $form['submission']['confirmation_wrapper']['confirmation'] = array( + $form['submission']['confirmation'] = array( '#type' => 'textarea', '#title' => t('Confirmation message'), '#description' => t('Message to be shown upon successful submission. If Redirect URL is set this displays as a message, otherwise it will be shown on its own page.'), '#default_value' => $node->webform['confirmation'], '#cols' => 40, '#rows' => 10, + '#text_format' => $node->webform['confirmation_format'], + '#parents' => array('confirmation_format'), ); - $form['submission']['confirmation_wrapper']['format'] = filter_form($node->webform['confirmation_format'], NULL, array('confirmation_format')); - // Redirect URL. $form['submission']['redirect_url'] = array( '#type' => 'textfield', @@ -52,7 +52,7 @@ '#type' => 'item', '#title' => t('Submission limit'), '#theme' => 'webform_advanced_submit_limit_form', - '#description' => t('Limit the number of submissions per user. A user is identified by their user login if logged-in, or by their IP Address and Cookie if anonymous. Use of cookies may be modified in the global Webform settings.', array('!url' => url('admin/settings/webform'))), + '#description' => t('Limit the number of submissions per user. A user is identified by their user login if logged-in, or by their IP Address and Cookie if anonymous. Use of cookies may be modified in the global Webform settings.', array('!url' => url('admin/config/content/webform'))), ); $form['submission']['submit_limit']['enforce_limit'] = array( '#type' => 'radios', @@ -255,7 +255,8 @@ /** * Theme the submit limit fieldset on the webform node form. */ -function theme_webform_advanced_submit_limit_form($form) { +function theme_webform_advanced_submit_limit_form($variables) { + $form = $variables['form']; $form['submit_limit']['#attributes']['class'] = 'webform-set-active'; $form['submit_interval']['#attributes']['class'] = 'webform-set-active'; $replacements = array( Index: includes/webform.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.admin.inc,v retrieving revision 1.5 diff -u -r1.5 webform.admin.inc --- includes/webform.admin.inc 3 Mar 2010 02:51:37 -0000 1.5 +++ includes/webform.admin.inc 8 Mar 2010 00:55:54 -0000 @@ -7,12 +7,12 @@ */ /** - * Menu callback for admin/settings/webform. + * Menu callback for admin/config/content/webform. */ function webform_admin_settings() { module_load_include('inc', 'webform', 'includes/webform.export'); - $node_types = node_get_types('names'); + $node_types = node_type_get_names(); $form['node_types'] = array( '#type' => 'checkboxes', '#title' => t('Webform-enabled content types'), @@ -163,14 +163,16 @@ variable_set('webform_node_types', $webform_types); } -function theme_webform_admin_settings($form) { +function theme_webform_admin_settings($variables) { + $form = $variables['form']; + // Format the components into a table. foreach (element_children($form['components']) as $key) { $row = array(); $row[] = $form['components'][$key]['#title']; $row[] = $form['components'][$key]['#description']; - unset($form['components'][$key]['#title']); - unset($form['components'][$key]['#description']); + $form['components'][$key]['#title'] = NULL; + $form['components'][$key]['#description'] = NULL; $row[] = array('data' => drupal_render($form['components'][$key]), 'align' => 'center'); $rows[] = $row; } @@ -178,11 +180,12 @@ // Create the table inside the form. $form['components']['table'] = array( - '#value' => theme('table', $header, $rows) + '#theme' => 'table', + '#header' => $header, + '#rows' => $rows, ); - $output = drupal_render($form); - return $output; + return drupal_render_children($form); } /** @@ -194,13 +197,14 @@ $nodes = array(); if ($webform_types) { $placeholders = implode(', ', array_fill(0, count($webform_types), "'%s'")); - $result = db_query(db_rewrite_sql("SELECT n.*, r.* FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid WHERE n.type IN ($placeholders)", 'n', 'nid', $webform_types), $webform_types); - while ($node = db_fetch_object($result)) { - $nodes[] = $node; - } + $nodes = db_select('node', 'n') + ->innerJoin('node_revisions', 'r', '=', array('n.vid', 'r.vid')) + ->condition('n.type', $webform_types, 'IN') + ->execute() + ->fetchAllAssoc('nid'); } - return theme('webform_admin_content', $nodes); + return theme('webform_admin_content', array('nodes' => $nodes)); } /** @@ -211,7 +215,7 @@ $webform_type_list = ''; $webform_type_count = count($webform_types); foreach ($webform_types as $n => $type) { - $webform_type_list .= l(node_get_types('name', $type), 'node/add/' . $type); + $webform_type_list .= l(node_type_get_name($type), 'node/add/' . $type); if ($n + 1 < $webform_type_count) { $webform_type_list .= $webform_type_count == 2 ? ' ' : ', '; } @@ -226,7 +230,8 @@ /** * Generate a list of all webforms avaliable on this site. */ -function theme_webform_admin_content($nodes) { +function theme_webform_admin_content($variables) { + $nodes = $variables['nodes']; $header = array( t('Title'), array('data' => t('View'), 'colspan' => '4'), @@ -249,7 +254,7 @@ if (empty($rows)) { $webform_types = webform_variable_get('webform_node_types'); if (empty($webform_types)) { - $message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the Webform settings page and enable Webform on at least one content type.', array('!url' => url('admin/settings/webform'))); + $message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the Webform settings page and enable Webform on at least one content type.', array('!url' => url('admin/config/content/webform'))); } else { $webform_type_list = webform_admin_type_list(); @@ -261,5 +266,5 @@ ); } - return theme('table', $header, $rows); + return theme('table', array('header' => $header, 'rows' => $rows)); } Index: tests/webform.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/tests/webform.test,v retrieving revision 1.5 diff -u -r1.5 webform.test --- tests/webform.test 9 Feb 2010 22:52:19 -0000 1.5 +++ tests/webform.test 8 Mar 2010 00:55:56 -0000 @@ -30,7 +30,7 @@ parent::setUp('webform', 'profile'); // Create a profile field to test %profile tokens. - db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')", 'Gender', 'profile_gender', '', 'Profile', 'textfield', 0, 0, 0, 2, 0, '', ''); + db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('Gender', 'profile_gender', '', 'Profile', 'textfield', 0, 0, 0, 2, 0, '', '')"); // Create a normal user that can view their own submissions. $permissions['userAccess'] = array( @@ -78,11 +78,11 @@ // Delete the webform admin and any created nodes. foreach ($this->webform_users as $account) { $uid = $account->uid; - $result = db_query('SELECT nid FROM {node} WHERE uid = %d', $uid); - while ($node = db_fetch_array($result)) { - node_delete($node['nid']); + $result = db_query('SELECT nid FROM {node} WHERE uid = :uid', array(':uid' => $uid)); + foreach ($result->execute() as $node) { + node_delete($node->nid); } - user_delete(array(), $uid); + user_cancel(array(), $uid, 'user_cancel_delete'); } parent::tearDown(); @@ -604,7 +604,7 @@ 'format' => '1', 'webform' => array( 'confirmation' => 'Thanks!', - 'confirmation_format' => FILTER_FORMAT_DEFAULT, + 'confirmation_format' => filter_default_format(), 'teaser' => '0', 'allow_draft' => '1', 'submit_text' => '', Index: tests/submission.test =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/tests/submission.test,v retrieving revision 1.5 diff -u -r1.5 submission.test --- tests/submission.test 3 Mar 2010 02:51:37 -0000 1.5 +++ tests/submission.test 8 Mar 2010 00:55:56 -0000 @@ -66,7 +66,7 @@ $submission_values = $value_type == 'sample' ? $this->testWebformPost() : array(); // Visit the node page with the "foo=bar" query, to test %get[] default values. - $this->drupalGet('node/' . $node->nid, array('query' => 'foo=bar')); + $this->drupalGet('node/' . $node->nid, array('query' => array('foo' => 'bar'))); $this->assertText($node->body, t('Webform node created and accessible at !url', array('!url' => 'node/' . $node->nid)), t('Webform')); // Submit our test data. Index: views/webform_handler_field_submission_count.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/views/webform_handler_field_submission_count.inc,v retrieving revision 1.4 diff -u -r1.4 webform_handler_field_submission_count.inc --- views/webform_handler_field_submission_count.inc 3 Mar 2010 02:51:37 -0000 1.4 +++ views/webform_handler_field_submission_count.inc 8 Mar 2010 00:55:56 -0000 @@ -49,8 +49,9 @@ } } elseif ($this->count_type == 'users') { - $sql = "SELECT COUNT(sid) FROM {webform_submissions} WHERE uid = %d"; - $output = db_result(db_query($sql, $values->{$this->aliases['uid']})); + $output = db_select('webform_submissions') + ->condition('uid', $values->{$this->aliases['uid']}) + ->countQuery->execute()->fetchField(); } return $output; Index: views/webform_handler_field_submission_link.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/views/webform_handler_field_submission_link.inc,v retrieving revision 1.3 diff -u -r1.3 webform_handler_field_submission_link.inc --- views/webform_handler_field_submission_link.inc 3 Mar 2010 02:51:37 -0000 1.3 +++ views/webform_handler_field_submission_link.inc 8 Mar 2010 00:55:56 -0000 @@ -83,7 +83,7 @@ case 'delete': $text = !empty($this->options['text']) ? $this->options['text'] : t('view'); $path = drupal_get_path_alias($_GET['q']); - $link = l($text, "node/$submission->nid/submission/$submission->sid/delete", array('query' => 'destination=' . $path)); + $link = l($text, "node/$submission->nid/submission/$submission->sid/delete", array('query' => array('destination' => $path))); $access = webform_submission_access($node, $submission, 'delete'); break; default: Index: views/webform_handler_field_form_body.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/views/webform_handler_field_form_body.inc,v retrieving revision 1.2 diff -u -r1.2 webform_handler_field_form_body.inc --- views/webform_handler_field_form_body.inc 3 Mar 2010 02:51:37 -0000 1.2 +++ views/webform_handler_field_form_body.inc 8 Mar 2010 00:55:56 -0000 @@ -30,7 +30,7 @@ $node = node_load($values->{$this->aliases['nid']}); if (node_access('view', $node)) { - $form_body = node_view($node, FALSE, FALSE); + $form_body = drupal_render(node_view($node)); } else { return; Index: templates/webform-submission-page.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/templates/webform-submission-page.tpl.php,v retrieving revision 1.2 diff -u -r1.2 webform-submission-page.tpl.php --- templates/webform-submission-page.tpl.php 26 Feb 2010 12:53:32 -0000 1.2 +++ templates/webform-submission-page.tpl.php 8 Mar 2010 00:55:56 -0000 @@ -19,6 +19,6 @@ - + Index: templates/webform-submission-navigation.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/templates/webform-submission-navigation.tpl.php,v retrieving revision 1.1 diff -u -r1.1 webform-submission-navigation.tpl.php --- templates/webform-submission-navigation.tpl.php 14 Jan 2010 06:12:47 -0000 1.1 +++ templates/webform-submission-navigation.tpl.php 8 Mar 2010 00:55:56 -0000 @@ -17,13 +17,13 @@ ?>
- array('class' => 'webform-submission-previous'), 'query' => ($mode == 'form' ? 'destination=' . $previous_url : NULL))); ?> + array('class' => 'webform-submission-previous'), 'query' => ($mode == 'form' ? array('destination' => $previous_url) : NULL))); ?> - array('class' => 'webform-submission-next'), 'query' => ($mode == 'form' ? 'destination=' . $next_url : NULL))); ?> + array('class' => 'webform-submission-next'), 'query' => ($mode == 'form' ? array('destination' => $next_url) : NULL))); ?> Index: templates/webform-submission-information.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/templates/webform-submission-information.tpl.php,v retrieving revision 1.1 diff -u -r1.1 webform-submission-information.tpl.php --- templates/webform-submission-information.tpl.php 14 Jan 2010 06:12:47 -0000 1.1 +++ templates/webform-submission-information.tpl.php 8 Mar 2010 00:55:56 -0000 @@ -13,9 +13,9 @@ ?>
- + $account)); ?>
l($node->title, 'node/' . $node->nid))); ?>
-
theme('username', $account))); ?>
+
theme('username', array('account' => $account)))); ?>
submitted, 'large'); ?>
remote_addr; ?>
Index: templates/webform-form.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/webform/templates/webform-form.tpl.php,v retrieving revision 1.1 diff -u -r1.1 webform-form.tpl.php --- templates/webform-form.tpl.php 22 May 2009 03:11:18 -0000 1.1 +++ templates/webform-form.tpl.php 8 Mar 2010 00:55:56 -0000 @@ -31,7 +31,7 @@ // Always print out the entire $form. This renders the remaining pieces of the // form that haven't yet been rendered above. - print drupal_render($form); + print drupal_render_children($form); // Print out the navigation again at the bottom. if (isset($form['submission_info']) || isset($form['navigation'])) {