Calling all Drupal developers!
Help us get this on the first page of Digg. DIGG NOW!
Help us get this on the first page of Digg. DIGG NOW!
<?php
// $Id: webform.module,v 1.124.2.18 2008/04/15 01:07:36 quicksketch Exp $
/**
* This module provides a simple way to create forms and questionnaires.
*
* The initial development of this module was sponsered by ÅF Industri AB, Open
* Source City and Karlstad University Library. Continued development sponsored
* by Lullabot.
*
* @author Nathan Haug <nate@lullabot.com>
* @author Pontus Ullgren <ullgren@user.sourceforge.net>
*/
/**
* Implemenation of hook_help().
*/
function webform_help($section = "admin/help#webform", $arg = NULL) {
$output = "";
switch ($section) {
case 'admin/settings/webform' :
$output = t('Webforms are forms and questionnaires. To add one, select <a href="!url">Create content -> Webform</a>.', array('!url' => url('node/add/webform')));
break;
case 'admin/help#webform' :
$output = t("<p>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.</p>
<p>Here is how to create one:</p>
<ul>
<li>Go to Create Content and add a webform</li>
<li>Add a description to be displayed as a teaser and above the actual form.</li>
<li>Add a confirmation message or redirect node that is to be displayed after successful submission.</li>
<li>Add one or more components to your form.</li>
<li>Optionally add an e-mail address to which submissions will be sent. If no email address is specified, no e-mail will be sent when submissions are made through the form.</li>
<li>Optionally select an e-mail (or hidden) component that will be used to populate the return e-mail address on any sent e-mail.</li>
<li>Optionally select a textfield (or hidden) component that will be used to populate the subject e-mail field on any sent e-mail.</li>
</ul>
<p>Help on adding and configuring the components will be shown after you add your first component.</p>
<p>The content of submitted forms is stored in the database table <i>webform_submitted_data</i> as key-value pairs.</p>
");
break;
case 'node/add#webform' :
$output = t("A webform can be a questionnaires, contact or request forms. It can be used to let visitors make contact, register for a event or to enable a complex survey.");
break;
case 'webform/helptext#variables' :
$output = t('Available variables are: %username, %useremail, %site, %date.');
$output .= ' '. t('You can also use %server[key] to add any of the special PHP <a href="http://www.php.net/reserved.variables#reserved.variables.server">$_SERVER</a> variables, %session[key] to add any of the special PHP <a href="http://www.php.net/reserved.variables#reserved.variables.session">$_SESSION</a> variables and %get[key] to create prefilled forms from the <a href="http://www.php.net/reserved.variables#reserved.variables.get">URL</a>. %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 profiles 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 varible %profile[profile_city].');
}
break;
case 'node/%/edit/components':
$output .= '<p>'. t('This page displays all the components currently configured for this webform node. You may add any number of components to the form, even multiple of the same type. To add a new component, fill in a name and select a type from the fields at the bottom of the table. Submit the form to create the new component or update any changed form values.') .'</p>';
$output .= '<p>'. t('Click on any existing component\'s name to edit its settings.') .'</p>';
break;
}
if (strstr($section, 'admin/settings/webform#')) {
// Call help hooks in plugins:
$components = webform_load_components(TRUE);
foreach ($components as $component) {
$help_function = "_webform_help_". $component;
if (function_exists($help_function)) {
$output .= $help_function($section);
}
}
}
return $output;
}
/**
* Implementation of hook_menu().
*/
function webform_menu() {
global $user;
$items = array();
// Submissions listing.
$items['admin/content/webform'] = array(
'title' => 'Webforms',
'page callback' => 'webform_admin_content',
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'description' => t('View and edit all the available webforms on your site.'),
'type' => MENU_NORMAL_ITEM,
);
// Admin Settings.
$items['admin/settings/webform'] = array(
'title' => 'Webform',
'page callback' => 'drupal_get_form',
'page arguments' => array('webform_admin_settings'),
'access callback' => 'user_access',
'access arguments' => array('administer site configuration'),
'description' => t('Global configuration of webform functionality.'),
'type' => MENU_NORMAL_ITEM,
);
// Node page tabs.
$items['node/%webform_menu/done'] = array(
'title' => 'Webform confirmation',
'page callback' => '_webform_confirmation',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_CALLBACK,
);
$items['node/%webform_menu/edit/configuration'] = array(
'title' => 'Configuration',
'page callback' => 'node_page_edit',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK);
$items['node/%webform_menu/edit/components'] = array(
'title' => 'Form components',
'page callback' => 'drupal_get_form',
'page arguments' => array('webform_components_form', 1),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'file' => 'webform_components.inc',
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
// Node component forms.
$items['node/%webform_menu/edit/components/%webform_menu_component'] = array(
'page arguments' => array('webform_component_edit_form', 1, 4),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/edit/components/%webform_menu_component/clone'] = array(
'page arguments' => array('webform_component_edit_form', 1, 4, TRUE),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/edit/components/%webform_menu_component/delete'] = array(
'page arguments' => array('webform_component_delete_form', 1, 4),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'type' => MENU_LOCAL_TASK,
);
// Node webform results.
$items['node/%webform_menu/webform-results'] = array(
'title' => 'Results',
'page callback' => 'webform_results_submissions',
'page arguments' => array(1),
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'file' => 'webform_report.inc',
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/webform-results/submissions'] = array(
'title' => 'Submissions',
'page callback' => 'webform_results_submissions',
'page arguments' => array(1),
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'file' => 'webform_report.inc',
'weight' => 4,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['node/%webform_menu/webform-results/analysis'] = array(
'title' => 'Analysis',
'page callback' => 'webform_results_analysis',
'page arguments' => array(1),
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'file' => 'webform_report.inc',
'weight' => 5,
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/webform-results/table'] = array(
'title' => 'Table',
'page callback' => 'webform_results_table',
'page arguments' => array(1),
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'file' => 'webform_report.inc',
'weight' => 6,
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/webform-results/download'] = array(
'title' => 'Download',
'page callback' => 'webform_results_download',
'page arguments' => array(1),
'access callback' => 'user_access',
'access arguments' => array('access webform results'),
'file' => 'webform_report.inc',
'weight' => 7,
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/webform-results/clear'] = array(
'title' => 'Clear',
'page callback' => 'drupal_get_form',
'page arguments' => array('webform_results_clear_form', 1),
'access callback' => 'user_access',
'access arguments' => array('clear webform results'),
'file' => 'webform_report.inc',
'weight' => 8,
'type' => MENU_LOCAL_TASK,
);
// Node submissions.
$items['node/%webform_menu/submissions'] = array(
'title' => 'Submissions',
'page callback' => 'webform_results_submissions',
'page arguments' => array(1, TRUE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, NULL, 'list'),
'file' => 'webform_report.inc',
'type' => MENU_CALLBACK,
);
$items['node/%webform_menu/submission/%webform_menu_submission'] = array(
'title' => 'Webform submission',
'page callback' => 'webform_client_form_load',
'page arguments' => array(1, 3, FALSE, FALSE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'view'),
'type' => MENU_CALLBACK,
);
$items['node/%webform_menu/submission/%webform_menu_submission/view'] = array(
'title' => 'View',
'page callback' => 'webform_client_form_load',
'page arguments' => array(1, 3, FALSE, FALSE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'view'),
'weight' => 0,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['node/%webform_menu/submission/%webform_menu_submission/edit'] = array(
'title' => 'Edit',
'page callback' => 'webform_client_form_load',
'page arguments' => array(1, 3, TRUE, FALSE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'edit'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);
$items['node/%webform_menu/submission/%webform_menu_submission/delete'] = array(
'title' => 'Delete',
'page callback' => 'drupal_get_form',
'page arguments' => array('webform_submission_delete_form', 1, 3),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'delete'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
* Menu loader callback. Load a webform node if the given nid is a webform.
*/
function webform_menu_load($nid) {
if (!is_numeric($nid)) {
return FALSE;
}
$node = node_load($nid);
if (!isset($node->type) || $node->type != 'webform') {
return FALSE;
}
return $node;
}
/**
* Menu loader callback. Load a webform submission if the given sid is a valid.
*/
function webform_menu_submission_load($sid) {
include_once(drupal_get_path('module', 'webform') ."/webform_submissions.inc");
$submission = webform_get_submission(arg(1), $sid);
return empty($submission) ? FALSE : $submission;
}
/**
* Menu loader callback. Load a webform component if the given cid is a valid.
*/
function webform_menu_component_load($cid) {
if ($cid == 'new') {
$components = webform_load_components();
$component = in_array(arg(5), array_keys($components)) ? array('type' => arg(5), 'name' => $_GET['name'], 'mandatory' => $_GET['mandatory'], 'pid' => $_GET['pid'], 'weight' => $_GET['weight']) : FALSE;
}
else {
$node = node_load(arg(1));
$component = isset($node->webform['components'][$cid]) ? $node->webform['components'][$cid] : FALSE;
}
return $component;
}
function webform_submission_access($node, $submission, $op = 'view', $account = NULL) {
global $user;
$account = !isset($account) ? $user : $account;
switch ($op) {
case 'view':
return user_access('access webform results') || (user_access('access own webform submissions') && ($account->uid == $submission['uid']));
case 'edit':
return user_access('edit webform submissions') || (user_access('edit own webform submissions') && ($account->uid == $submission['uid']));
case 'delete':
return user_access('edit webform submissions') || (user_access('edit own webform submissions') && ($account->uid == $submission['uid'])) || user_access('clear webform results');
case 'list':
return user_access('access webform results') || user_access('access webform submissions') || (user_access('access own webform submissions') && $user->uid);
}
}
/**
* Implementation of hook_perm().
*/
function webform_perm() {
return array("create webforms", "edit own webforms", "edit webforms", "access webform results", "clear webform results", "access own webform submissions", "edit own webform submissions", "edit webform submissions", "use PHP for additional processing");
}
/**
* Implementation of hook_theme().
*/
function webform_theme() {
$theme = array(
// webform.module.
'webform_mail_components_form' => array(
'arguments' => array('form' => NULL),
),
'webform_mail_settings_form' => array(
'arguments' => array('form' => NULL),
),
'webform_advanced_submit_limit_form' => array(
'arguments' => array('form' => NULL),
),
'webform_admin_settings' => array(
'arguments' => array('form' => NULL),
),
'webform_confirmation' => array(
'arguments' => array('node' => NULL, 'sid' => NULL),
),
'webform_mail_message' => array(
'arguments' => array('form_values' => NULL, 'node' => NULL, 'sid' => NULL, 'cid' => NULL),
),
'webform_mail_fields' => array(
'arguments' => array('cid' => NULL, 'value' => NULL, 'node' => NULL, 'indent' => NULL),
),
'webform_mail_headers' => array(
'arguments' => array('form_values' => NULL, 'node' => NULL, 'sid' => NULL, 'cid' => NULL),
),
'webform_admin_content' => array(
'arguments' => array('nodes' => NULL),
),
// webform_components.inc.
'webform_components_form' => array(
'arguments' => array('form' => NULL),
),
// webform_report.inc.
'webform_results_submissions_header' => array(
'arguments' => array('node' => NULL),
),
'webform_results_submissions' => array(
'arguments' => array('node' => NULL, 'submissions' => NULL),
),
'webform_results_table_header' => array(
'arguments' => array('node' => NULL),
),
'webform_results_table' => array(
'arguments' => array('node' => NULL, 'components' => NULL, 'submissions' => NULL, 'node' => NULL),
),
);
// Theme functions in all components.
$components = webform_load_components(TRUE);
foreach ($components as $component) {
$theme_hook = "_webform_theme_". $component;
if (function_exists($theme_hook)) {
$theme = array_merge($theme, $theme_hook());
}
}
return $theme;
}
/**
* Implementation of hook_node_info().
*/
function webform_node_info() {
return array(
'webform' => array(
'name' => t('Webform'),
'module' => 'webform',
'description' => t('Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.'),
)
);
}
/**
* Implemenation of hook_access().
*/
function webform_access($op, $node) {
global $user;
switch ($op) {
case "create":
return user_access("create webforms");
case "update":
case "delete":
return user_access("edit webforms") || (user_access("edit own webforms") && ($user->uid == $node->uid));
}
}
/**
* Implementation of hook_forms().
* All webform_client_form forms share the same form handler
*/
function webform_forms($form_id) {
$forms = array();
if (strpos($form_id, 'webform_client_form_') === 0) {
$forms[$form_id]['callback'] = 'webform_client_form';
}
return $forms;
}
/**
* Implementation of hook_file_download().
*
* Only allow users with view webform submissions to download files.
*/
function webform_file_download($file) {
$file = file_check_location(file_directory_path() .'/'. $file, file_directory_path() .'/webform/');
if ($file && user_access('access webform results')) {
$info = image_get_info(file_create_path($file));
return array('Content-type: '. $info['mime_type']);
}
}
/**
* Implemenation of hook_insert().
*/
function webform_insert($node) {
include_once(drupal_get_path('module', 'webform') .'/webform_components.inc');
// If this is submitted from the node form, do a little extra cleanup.
if (isset($node->op) && $node->op == $node->submit) {
webform_submit($node);
}
// Insert the Webform.
db_query("INSERT INTO {webform} (nid, confirmation, teaser, submit_text, submit_limit, submit_interval, email, email_from_name, email_from_address, email_subject, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['teaser'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['email'], $node->webform['email_from_name'], $node->webform['email_from_address'], $node->webform['email_subject'], $node->webform['additional_validate'], $node->webform['additional_submit']);
// Insert the components into the database.
if (isset($node->webform['components']) && !empty($node->webform['components'])) {
foreach ($node->webform['components'] as $cid => $component) {
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)",
$node->nid, $cid, $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), ($component['mandatory'] ? 1 : 0), $component['weight']
);
}
}
}
/**
* Implemenation of hook_update().
*/
function webform_update($node) {
// 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);
webform_insert($node);
}
/**
* Implemenation of hook_delete().
*/
function webform_delete(&$node) {
db_query("DELETE FROM {webform} WHERE nid = %d", $node->nid);
db_query("DELETE FROM {webform_component} WHERE nid = %d", $node->nid);
watchdog('webform', 'webform "'. $node->title .'" deleted', WATCHDOG_NOTICE);
}
/**
* Implementation of hook_load().
*/
function webform_load($node) {
$additions = new stdClass();
if ($webform = db_fetch_array(db_query("SELECT * FROM {webform} WHERE nid = %d", $node->nid))) {
$additions->webform = $webform;
}
else {
$additions->webform = array(
'confirmation' => '',
'teaser' => 0,
'submit_text' => '',
'submit_limit' => -1,
'submit_interval' => -1,
'email' => '',
'email_from_name' => 'default',
'email_from_address' => 'default',
'email_subject' => 'default',
'additional_validate' => '',
'additional_submit' => '',
);
}
$additions->webform['components'] = array();
$additions->webform['additional_emails'] = array();
$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'];
if (isset($component['extra']['email']) && $component['extra']['email']) {
$additions->webform['additional_emails'][$c['cid']] = $c['cid'];
}
}
// 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']);
}
return $additions;
}
/**
* Implementation of hook_link().
* Always add a "view form" link.
*/
function webform_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
if ($node->type == 'webform') {
if ($teaser && !$node->webform['teaser']) {
$links['webform_goto'] = array(
'title' => t('Go to form'),
'href' => "node/$node->nid",
'attributes' => array('title' => t('View this form.'), 'class' => 'read-more')
);
}
}
return $links;
}
/**
* Implementation of hook_form()
* Creates the standard form for editing or creating a webform.
*/
function webform_form(&$node, &$param) {
$form['webform'] = array(
'#type' => 'markup',
'#tree' => TRUE,
);
// Set node defaults if empty.
if (!isset($node->nid) && !isset($node->webform)) {
$node->nid = 0;
$additions = webform_load($node);
$node->webform = $additions->webform;
$node->nid = NULL;
}
/* Save Components in a value (helps with clone.module) */
$form['webform']['components'] = array(
'#type' => 'value',
'#value' => $node->webform['components'],
);
/* Start Edit Form */
$form['webform']['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Webform Settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => -4,
'#parents' => array('webform'),
);
$form['webform']['settings']['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $node->title,
'#maxlength' => 128,
'#required' => TRUE,
'#tree' => FALSE,
);
$form['webform']['settings']['body'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t('Text to be shown as teaser and before the form.'),
'#default_value' => $node->body,
'#cols' => 40,
'#rows' => 10,
'#tree' => FALSE,
);
$form['webform']['settings']['confirmation'] = array(
'#type' => 'textarea',
'#title' => t("Confirmation message or redirect URL"),
'#description' => t("Message to be shown upon successful submission or a path to a redirect page. Redirect pages must start with <em>http://</em> for external sites or <em>internal:</em> for an internal path. i.e. <em>http://www.example.com</em> or <em>internal:node/10</em>"),
'#default_value' => $node->webform['confirmation'],
'#cols' => 40,
'#rows' => 10,
);
$form['webform']['settings']['format'] = filter_form($node->format);
/* End Edit Form */
/* Start E-mail Settings Form */
$form['webform']['mail_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Webform mail settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => -2,
'#parents' => array('webform'),
'#theme' => 'webform_mail_settings_form',
);
$form['webform']['mail_settings']['email'] = array(
'#type' => 'textfield',
'#title' => t("E-mail to address"),
'#default_value' => $node->webform['email'],
'#description' => t('Form submissions will be e-mailed to this address. Leave blank for none. Multiple e-mail addresses may be separated by commas.'),
);
$form['webform']['mail_settings']['email_components'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#theme' => 'webform_mail_components_form',
'#title' => t('Conditional e-mail recipients'),
'#description' => t('The settings below allow you to send e-mails to multiple recipients based off the value of a component.'),
'#node' => $node,
);
$options = _webform_component_options($node->webform['components'], 'email');
$default_value = array();
if (is_array($node->webform['components'])) {
foreach ($node->webform['components'] as $cid => $component) {
if (isset($component['extra']['email']) && $component['extra']['email']) {
$default_value[] = $cid;
}
}
}
$form['webform']['mail_settings']['email_components']['email_components'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $default_value,
'#parents' => array('webform', 'email_components'),
);
foreach (array('from_name', 'from_address', 'subject') as $field) {
switch ($field) {
case 'from_name':
$default_value = webform_variable_get('webform_default_from_name');
$title = t('E-mail from name');
$description = t('After adding components to this form any email, select, or hidden form element may be selected as the sender\'s name for e-mails.');
break;
case 'from_address':
$default_value = webform_variable_get('webform_default_from_address');
$title = t('E-mail from address');
$description = t('After adding components to this form any textfield, select, or hidden form element may be selected as the sender\'s e-mail address.');
break;
case 'subject':
$default_value = webform_variable_get('webform_default_subject');
$title = t('E-mail subject');
$description = t('After adding components to this form any textfield, select, or hidden form element may be selected as the subject for e-mails.');
break;
}
$form['webform']['mail_settings']['email_'. $field .'_option'] = array(
'#title' => $title,
'#type' => 'radios',
'#default_value' => is_numeric($node->webform['email_'. $field]) ? 'component' : ((empty($default_value) || ($node->webform['email_'. $field] != 'default' && isset($node->webform['email_'. $field]))) ? 'custom' : 'default'),
'#description' => $description,
);
if (!empty($default_value)) {
$form['webform']['mail_settings']['email_'. $field .'_option']['#options']['default'] = $default_value;
}
$form['webform']['mail_settings']['email_'. $field .'_option']['#options']['custom'] = 'custom';
$form['webform']['mail_settings']['email_'. $field .'_option']['#options']['component'] = 'component';
$form['webform']['mail_settings']['email_'. $field .'_custom'] = array(
'#type' => 'textfield',
'#size' => 40,
'#default_value' => (!is_numeric($node->webform['email_'. $field]) && $node->webform['email_'. $field] != 'default') ? $node->webform['email_'. $field] : NULL,
);
$options = _webform_component_options($node->webform['components'], $field == 'from_address' ? 'email' : 'string');
$form['webform']['mail_settings']['email_'. $field .'_component'] = array(
'#type' => 'select',
'#default_value' => is_numeric($node->webform['email_'. $field]) ? $node->webform['email_'. $field] : NULL,
'#options' => empty($options) ? array('' => 'No available components') : $options,
'#disabled' => empty($options) ? TRUE : FALSE,
'#weight' => 6,
);
}
/* End mail settings form */
/* Start advanced settings form */
$form['webform']['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Webform advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => -1,
'#parents' => array('webform'),
);
$form['webform']['advanced']['teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Show complete form in teaser'),
'#default_value' => $node->webform['teaser'],
'#description' => t('Display the entire form in the teaser display of this node.'),
);
$form['webform']['advanced']['submit_limit'] = array(
'#type' => 'fieldset',
'#title' => t('Limit the number of submissions a user may send within a specified time period'),
'#theme' => 'webform_advanced_submit_limit_form',
);
$form['webform']['advanced']['submit_limit']['enforce_limit'] = array(
'#type' => 'radios',
'#options' => array('no' =>