security updates
have to check views and entityreference for custom patches
This commit is contained in:
@@ -166,6 +166,10 @@ function webform_expand_date($element) {
|
||||
$timestring = webform_strtodate('c', $element['#default_value'], $timezone);
|
||||
$element['#default_value'] = webform_date_array($timestring, 'date');
|
||||
}
|
||||
// Prevent an error in PHP 5.4 caused by core's treatment of the #value.
|
||||
if (isset($element['#value'])) {
|
||||
unset($element['#value']);
|
||||
}
|
||||
|
||||
// Set defaults according to existing #default_value (set by Form API)
|
||||
if (isset($element['#default_value']['month']) || isset($element['#default_value']['day']) || isset($element['#default_value']['year'])) {
|
||||
@@ -200,6 +204,8 @@ function webform_expand_date($element) {
|
||||
break;
|
||||
}
|
||||
unset($element[$type]['#value']);
|
||||
$element[$type]['#title'] = $none;
|
||||
$element[$type]['#title_display'] = 'invisible';
|
||||
$element[$type]['#default_value'] = isset($default_values[$type]) ? $default_values[$type] : NULL;
|
||||
$element[$type]['#options'] = array('' => $none) + $element[$type]['#options'];
|
||||
}
|
||||
@@ -233,9 +239,9 @@ function webform_expand_date($element) {
|
||||
function theme_webform_date($variables) {
|
||||
$element = $variables['element'];
|
||||
|
||||
$element['year']['#attributes']['class'] = array('year');
|
||||
$element['month']['#attributes']['class'] = array('month');
|
||||
$element['day']['#attributes']['class'] = array('day');
|
||||
$element['year']['#attributes']['class'][] = 'year';
|
||||
$element['month']['#attributes']['class'][] = 'month';
|
||||
$element['day']['#attributes']['class'][] = 'day';
|
||||
|
||||
// Add error classes to all items within the element.
|
||||
if (form_get_error($element)) {
|
||||
|
@@ -62,7 +62,7 @@ function _webform_render_fieldset($component, $value = NULL, $filter = TRUE) {
|
||||
'#description' => $filter ? _webform_filter_descriptions($component['extra']['description'], $node) : $component['extra']['description'],
|
||||
'#collapsible' => $component['extra']['collapsible'],
|
||||
'#collapsed' => $component['extra']['collapsed'],
|
||||
'#attributes' => array('class' => array('webform-component-fieldset'), 'id' => 'webform-component-' . $component['form_key']),
|
||||
'#attributes' => array('class' => array('webform-component-fieldset')),
|
||||
'#pre_render' => array('webform_fieldset_prerender', 'webform_element_title_display'),
|
||||
'#translatable' => array('title', 'description'),
|
||||
);
|
||||
@@ -74,7 +74,7 @@ function _webform_render_fieldset($component, $value = NULL, $filter = TRUE) {
|
||||
* Pre-render function to set a fieldset ID.
|
||||
*/
|
||||
function webform_fieldset_prerender($element) {
|
||||
$element['#attributes']['id'] = 'webform-component-' . str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));
|
||||
$element['#id'] = 'webform-component-' . str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
@@ -212,7 +212,7 @@ function _webform_edit_file_check_directory($element) {
|
||||
$scheme = $element['extra']['scheme']['#value'];
|
||||
$directory = $element['extra']['directory']['#value'];
|
||||
|
||||
$destination_dir = file_stream_wrapper_uri_normalize($scheme . '://' . $directory . '/webform');
|
||||
$destination_dir = file_stream_wrapper_uri_normalize($scheme . '://webform/' . $directory);
|
||||
|
||||
// Sanity check input to prevent use parent (../) directories.
|
||||
if (preg_match('/\.\.[\/\\\]/', $destination_dir . '/')) {
|
||||
|
@@ -419,6 +419,7 @@ function theme_webform_grid($variables) {
|
||||
// Render each radio button in the row.
|
||||
$radios = form_process_radios($question_element);
|
||||
foreach (element_children($radios) as $key) {
|
||||
$radios[$key]['#title'] = $question_element['#title'] . ' - ' . $radios[$key]['#title'];
|
||||
$radios[$key]['#title_display'] = 'invisible';
|
||||
$row[] = array('data' => drupal_render($radios[$key]), 'class' => array('checkbox', 'webform-grid-option'));
|
||||
}
|
||||
|
@@ -66,9 +66,6 @@ function _webform_render_markup($component, $value = NULL, $filter = TRUE) {
|
||||
'#translatable' => array('title', 'markup'),
|
||||
);
|
||||
|
||||
// TODO: Remove when #markup becomes available in D7.
|
||||
$element['#value'] = $element['#markup'];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@ function _webform_defaults_number() {
|
||||
'type' => 'textfield',
|
||||
'field_prefix' => '',
|
||||
'field_suffix' => '',
|
||||
'disabled' => 0,
|
||||
'unique' => 0,
|
||||
'title_display' => 0,
|
||||
'description' => '',
|
||||
@@ -99,6 +100,15 @@ function _webform_edit_number($component) {
|
||||
'#weight' => 1.2,
|
||||
'#parents' => array('extra', 'field_suffix'),
|
||||
);
|
||||
$form['display']['disabled'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Disabled'),
|
||||
'#return_value' => 1,
|
||||
'#description' => t('Make this field non-editable. Useful for setting an unchangeable default value.'),
|
||||
'#weight' => 11,
|
||||
'#default_value' => $component['extra']['disabled'],
|
||||
'#parents' => array('extra', 'disabled'),
|
||||
);
|
||||
$form['display']['decimals'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Decimal places'),
|
||||
@@ -266,9 +276,17 @@ function _webform_render_number($component, $value = NULL, $filter = TRUE) {
|
||||
'#max' => $component['extra']['max'],
|
||||
'#step' => $component['extra']['step'] ? abs($component['extra']['step']) : '',
|
||||
'#integer' => $component['extra']['integer'],
|
||||
'#translatable' => array('title', 'description'),
|
||||
'#point' => $component['extra']['point'],
|
||||
'#separator' => $component['extra']['separator'],
|
||||
'#decimals' => $component['extra']['decimals'],
|
||||
'#translatable' => array('title', 'description', 'field_prefix', 'field_suffix'),
|
||||
);
|
||||
|
||||
// Set the decimal count to zero for integers.
|
||||
if ($element['#integer'] && $element['#decimals'] === '') {
|
||||
$element['#decimals'] = 0;
|
||||
}
|
||||
|
||||
// Flip the min and max properties to make min less than max if needed.
|
||||
if ($element['#min'] !== '' && $element['#max'] !== '' && $element['#min'] > $element['#max']) {
|
||||
$max = $element['#min'];
|
||||
@@ -308,7 +326,15 @@ function _webform_render_number($component, $value = NULL, $filter = TRUE) {
|
||||
|
||||
// Set user-entered values.
|
||||
if (isset($value[0])) {
|
||||
$element['#default_value'] = $value[0];
|
||||
// If the value has been standardized, convert it to the expected format
|
||||
// for display to the user.
|
||||
if (webform_number_format_match($value[0], '.', '')) {
|
||||
$element['#default_value'] = _webform_number_format($component, $value[0]);
|
||||
}
|
||||
// Otherwise use the user-defined input.
|
||||
else {
|
||||
$element['#default_value'] = $value[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce uniqueness.
|
||||
@@ -316,6 +342,16 @@ function _webform_render_number($component, $value = NULL, $filter = TRUE) {
|
||||
$element['#element_validate'][] = 'webform_validate_unique';
|
||||
}
|
||||
|
||||
// Set readonly if disabled.
|
||||
if ($component['extra']['disabled']) {
|
||||
if ($filter) {
|
||||
$element['#attributes']['readonly'] = 'readonly';
|
||||
}
|
||||
else {
|
||||
$element['#disabled'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
@@ -342,8 +378,8 @@ function _webform_display_number($component, $value, $format = 'html') {
|
||||
*/
|
||||
function theme_webform_display_number($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'];
|
||||
$prefix = $element['#format'] == 'html' ? '' : $element['#field_prefix'];
|
||||
$suffix = $element['#format'] == 'html' ? '' : $element['#field_suffix'];
|
||||
$value = $element['#format'] == 'html' ? check_plain($element['#value']) : $element['#value'];
|
||||
return $value !== '' ? ($prefix . $value . $suffix) : ' ';
|
||||
}
|
||||
@@ -365,28 +401,17 @@ function _webform_analysis_number($component, $sids = array(), $single = FALSE)
|
||||
|
||||
$population = array();
|
||||
$submissions = 0;
|
||||
$nonzero = 0;
|
||||
$not_empty = 0;
|
||||
$non_zero = 0;
|
||||
$non_empty = 0;
|
||||
$sum = 0;
|
||||
|
||||
$result = $query->execute();
|
||||
foreach ($result as $data) {
|
||||
$value = trim($data['data']);
|
||||
if ($value == '') {
|
||||
$number = 0.0;
|
||||
}
|
||||
else {
|
||||
$number = $value * 1.0;
|
||||
}
|
||||
|
||||
if ($value !== '') {
|
||||
$not_empty++;
|
||||
}
|
||||
|
||||
if ($number > 0) {
|
||||
$nonzero++;
|
||||
$sum += $number;
|
||||
}
|
||||
$number = (float)$value;
|
||||
$non_empty += (integer)($value !== '');
|
||||
$non_zero += (integer)($number != 0.0);
|
||||
$sum += $number;
|
||||
$population[] = $number;
|
||||
$submissions++;
|
||||
}
|
||||
@@ -394,10 +419,10 @@ function _webform_analysis_number($component, $sids = array(), $single = FALSE)
|
||||
|
||||
// Average and population count.
|
||||
if ($component['extra']['excludezero']) {
|
||||
$average = $nonzero ? ($sum / $nonzero) : 0;
|
||||
$average = $non_zero ? ($sum / $non_zero) : 0;
|
||||
$average_title = t('Average !mu excluding zeros/blanks', array('!mu' => $advanced_stats ? '(μ)' : ''));
|
||||
// Sample (sub-set of total population).
|
||||
$population_count = $nonzero - 1;
|
||||
$population_count = $non_zero - 1;
|
||||
$sigma = 'sd';
|
||||
$description = t('sample');
|
||||
}
|
||||
@@ -414,8 +439,8 @@ function _webform_analysis_number($component, $sids = array(), $single = FALSE)
|
||||
$average = _webform_number_format($component, $average);
|
||||
$sum = _webform_number_format($component, $sum);
|
||||
|
||||
$rows[0] = array(t('Zero/blank'), ($submissions - $nonzero));
|
||||
$rows[1] = array(t('User entered value'), $not_empty);
|
||||
$rows[0] = array(t('Zero/blank'), ($submissions - $non_zero));
|
||||
$rows[1] = array(t('User entered value'), $non_empty);
|
||||
$rows[2] = array(t('Sum') . ($advanced_stats ? ' (Σ)' : ''), $sum);
|
||||
$rows[3] = array($average_title, $average);
|
||||
|
||||
@@ -438,6 +463,11 @@ function _webform_analysis_number($component, $sids = array(), $single = FALSE)
|
||||
$stddev = sqrt($stddev);
|
||||
}
|
||||
|
||||
// Skip the rest of the distribution rows if standard deviation is 0.
|
||||
if (empty($stddev)) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
// Build normal distribution table rows.
|
||||
$count = array();
|
||||
$percent = array();
|
||||
@@ -536,12 +566,20 @@ function _webform_csv_data_number($component, $export_options, $value) {
|
||||
* None. Calls a form_set_error if the number is not valid.
|
||||
*/
|
||||
function _webform_validate_number($element, &$form_state) {
|
||||
// Trim spaces for basic cleanup.
|
||||
$value = trim($element['#value']);
|
||||
form_set_value($element, $value, $form_state);
|
||||
|
||||
if ($value != '') {
|
||||
// First check that the entered value matches the expected value.
|
||||
if (!webform_number_format_match($value, $element['#point'], $element['#separator'])) {
|
||||
form_error($element, t('%name field value must format numbers as "@example".', array('%name' => $element['#title'], '@example' => webform_number_format(12345.6789, $element['#decimals'], $element['#point'], $element['#separator']))));
|
||||
return;
|
||||
}
|
||||
|
||||
// Numeric test.
|
||||
if (is_numeric($value)) {
|
||||
$numeric_value = webform_number_standardize($value, $element['#point']);
|
||||
if (is_numeric($numeric_value)) {
|
||||
// Range test.
|
||||
if ($element['#min'] != '' && $element['#max'] != '') {
|
||||
// Flip minimum and maximum if needed.
|
||||
@@ -553,25 +591,25 @@ function _webform_validate_number($element, &$form_state) {
|
||||
$min = $element['#max'];
|
||||
$max = $element['#min'];
|
||||
}
|
||||
if ($value > $max || $value < $min) {
|
||||
form_error($element, t('%name field value of @value should be in the range @min to @max.', array('%name' => $element['#title'], '@value' => $value, '@min' => $min, '@max' => $max)));
|
||||
if ($numeric_value > $max || $numeric_value < $min) {
|
||||
form_error($element, t('%name field value of @value should be in the range @min to @max.', array('%name' => $element['#title'], '@value' => $value, '@min' => $element['#min'], '@max' => $element['#max'])));
|
||||
}
|
||||
}
|
||||
elseif ($element['#max'] != '' && $value > $element['#max']) {
|
||||
elseif ($element['#max'] != '' && $numeric_value > $element['#max']) {
|
||||
form_error($element, t('%name field value must be less than @max.', array('%name' => $element['#title'], '@max' => $element['#max'])));
|
||||
}
|
||||
elseif ($element['#min'] != '' && $value < $element['#min']) {
|
||||
elseif ($element['#min'] != '' && $numeric_value < $element['#min']) {
|
||||
form_error($element, t('%name field value must be greater than @min.', array('%name' => $element['#title'], '@min' => $element['#min'])));
|
||||
}
|
||||
|
||||
// Integer test.
|
||||
if ($element['#integer'] && !is_int($value * 1)) {
|
||||
if ($element['#integer'] && !is_int($numeric_value * 1)) {
|
||||
form_error($element, t('%name field value of @value must be an integer.', array('%name' => $element['#title'], '@value' => $value)));
|
||||
}
|
||||
|
||||
// Step test.
|
||||
$starting_number = $element['#min'] ? $element['#min'] : 0;
|
||||
if ($element['#step'] != 0 && fmod($element['#value'] - $starting_number, $element['#step']) != 0) {
|
||||
if ($element['#step'] != 0 && webform_modulo($numeric_value - $starting_number, $element['#step']) != 0) {
|
||||
$samples = array(
|
||||
$starting_number,
|
||||
$starting_number + ($element['#step'] * 1),
|
||||
@@ -590,7 +628,20 @@ function _webform_validate_number($element, &$form_state) {
|
||||
form_error($element, t('%name field value of @value must be numeric.', array('%name' => $element['#title'], '@value' => $value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements _webform_submit_component().
|
||||
*/
|
||||
function _webform_submit_number($component, $value) {
|
||||
// Because _webform_validate_number() ensures the format matches when moving
|
||||
// forward through a form, this should always pass before saving into the
|
||||
// database. When moving backwards in a form, do not adjust the value, since
|
||||
// it has not yet been validated.
|
||||
if (webform_number_format_match($value, $component['extra']['point'], $component['extra']['separator'])) {
|
||||
$value = webform_number_standardize($value, $component['extra']['point']);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -696,15 +747,38 @@ function _webform_number_select_options($component) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply number format.
|
||||
* Apply number format based on a component and number value.
|
||||
*/
|
||||
function _webform_number_format($component, $value) {
|
||||
return webform_number_format($value, $component['extra']['decimals'], $component['extra']['point'], $component['extra']['separator']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a provided number string matches an expected format.
|
||||
*
|
||||
* This function allows the thousands separator to be optional, but decimal
|
||||
* points must be in the right location.
|
||||
*
|
||||
* Based on http://stackoverflow.com/questions/5917082/regular-expression-to-match-numbers-with-or-without-commas-and-decimals-in-text.
|
||||
*/
|
||||
function webform_number_format_match($value, $point, $separator) {
|
||||
return preg_match('/^(-? ?[1-9](?:\d{0,2})(?:' . ($separator ? (preg_quote($separator, '/') . '?') : '') . '\d{3})*(?:' . preg_quote($point, '/') . '\d*[0-9])?|0?' . preg_quote($point, '/') . '\d*[1-9]|0)$/', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a number with thousands separator, decimal point, and decimal places.
|
||||
*
|
||||
* This function is a wrapper around PHP's native number_format(), but allows
|
||||
* the decimal places parameter to be NULL or an empty string, resulting in a
|
||||
* behavior of no change to the decimal places.
|
||||
*/
|
||||
function webform_number_format($value, $decimals = NULL, $point = '.', $separator = ',') {
|
||||
if (!is_numeric($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If no decimal places are specified, do a best guess length of decimals.
|
||||
$decimals = $component['extra']['decimals'];
|
||||
if ($decimals === '') {
|
||||
if (is_null($decimals) || $decimals === '') {
|
||||
// If it's an integer, no decimals needed.
|
||||
if (is_int(($value . '') * 1)) {
|
||||
$decimals = 0;
|
||||
@@ -717,5 +791,30 @@ function _webform_number_format($component, $value) {
|
||||
}
|
||||
}
|
||||
|
||||
return number_format($value, $decimals, $component['extra']['point'], $component['extra']['separator']);
|
||||
return number_format($value, $decimals, $point, $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a number, convert it to string compatible with a PHP float.
|
||||
*
|
||||
* @param string $value
|
||||
* The string value to be standardized into a numeric string.
|
||||
* @param $point
|
||||
* The point separator between the whole number and the decimals.
|
||||
*/
|
||||
function webform_number_standardize($value, $point) {
|
||||
// For simplicity, strip everything that's not the decimal point.
|
||||
$value = preg_replace('/[^\-0-9' . preg_quote($point, '/') . ']/', '', $value);
|
||||
// Convert the decimal point to a period.
|
||||
$value = str_replace($point, '.', $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom modulo function that properly handles float division.
|
||||
*
|
||||
* See https://drupal.org/node/1601968.
|
||||
*/
|
||||
function webform_modulo($a, $b) {
|
||||
return $a - $b * (($b < 0) ? ceil($a / $b) : floor($a / $b));
|
||||
}
|
@@ -316,46 +316,36 @@ function _webform_render_select($component, $value = NULL, $filter = TRUE) {
|
||||
// Set the component options.
|
||||
$element['#options'] = $options;
|
||||
|
||||
// Set the default value.
|
||||
if (isset($value)) {
|
||||
if ($component['extra']['multiple']) {
|
||||
// Set the value as an array.
|
||||
$element['#default_value'] = array();
|
||||
foreach ((array) $value as $key => $option_value) {
|
||||
$element['#default_value'][] = $option_value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Set the value as a single string.
|
||||
$element['#default_value'] = '';
|
||||
foreach ((array) $value as $option_value) {
|
||||
$element['#default_value'] = $option_value;
|
||||
}
|
||||
}
|
||||
// Use the component's default value if the component is currently empty.
|
||||
if (!isset($value)) {
|
||||
// The default for multiple selects is a comma-delimited list, without white-space or empty entries.
|
||||
$value = $component['extra']['multiple'] ? array_filter(array_map('trim', explode(',', $default_value)), 'strlen') : $default_value;
|
||||
}
|
||||
elseif ($default_value !== '') {
|
||||
// Convert default value to a list if necessary.
|
||||
if ($component['extra']['multiple']) {
|
||||
$varray = explode(',', $default_value);
|
||||
foreach ($varray as $key => $v) {
|
||||
$v = trim($v);
|
||||
if ($v !== '') {
|
||||
$element['#default_value'][] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$element['#default_value'] = $default_value;
|
||||
}
|
||||
}
|
||||
elseif ($component['extra']['multiple']) {
|
||||
|
||||
// Convert all values into an array; component may now be single but was previously multiple, or vice-versa
|
||||
$value = (array)$value;
|
||||
|
||||
// Set the default value. Note: "No choice" is stored as an empty string,
|
||||
// which will match a 0 key for radios; NULL is used to avoid unintentional
|
||||
// defaulting to the 0 option.
|
||||
if ($component['extra']['multiple']) {
|
||||
// Set the value as an array.
|
||||
$element['#default_value'] = array();
|
||||
foreach ($value as $option_value) {
|
||||
$element['#default_value'][] = $option_value === '' ? NULL : $option_value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Set the value as a single string.
|
||||
$option_value = reset($value);
|
||||
$element['#default_value'] = $option_value === '' ? NULL : $option_value;
|
||||
}
|
||||
|
||||
if ($component['extra']['other_option'] && module_exists('select_or_other')) {
|
||||
// Set display as a select_or_other element:
|
||||
$element['#type'] = 'select_or_other';
|
||||
$element['#other'] = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...');
|
||||
$element['#translatable'][] = 'other';
|
||||
$element['#other_title'] = $element['#title'] . ' ' . $element['#other'];
|
||||
$element['#other_title_display'] = 'invisible';
|
||||
$element['#other_unknown_defaults'] = 'other';
|
||||
@@ -389,11 +379,6 @@ function _webform_render_select($component, $value = NULL, $filter = TRUE) {
|
||||
$element['#type'] = 'checkboxes';
|
||||
$element['#theme_wrappers'] = array_merge(array('checkboxes'), $element['#theme_wrappers']);
|
||||
$element['#process'] = array_merge(element_info_property('checkboxes', '#process'), array('webform_expand_select_ids'));
|
||||
|
||||
// Entirely replace the normal expand checkboxes with our custom version.
|
||||
// This helps render checkboxes in multipage forms.
|
||||
$process_key = array_search('form_process_checkboxes', $element['#process']);
|
||||
$element['#process'][$process_key] = 'webform_expand_checkboxes';
|
||||
}
|
||||
else {
|
||||
// Set display as a radio set.
|
||||
@@ -438,35 +423,6 @@ function webform_expand_select_or_other($element) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drupal 6 hack that properly *renders* checkboxes in multistep forms. This is
|
||||
* different than the value hack needed in Drupal 5, which is no longer needed.
|
||||
*/
|
||||
function webform_expand_checkboxes($element) {
|
||||
// Elements that have a value set are already in the form structure cause
|
||||
// them not to be written when the expand_checkboxes function is called.
|
||||
$default_value = array();
|
||||
foreach (element_children($element) as $key) {
|
||||
if (isset($element[$key]['#default_value'])) {
|
||||
$default_value[$key] = $element[$key]['#default_value'];
|
||||
unset($element[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$element = form_process_checkboxes($element);
|
||||
|
||||
// Escape the values of checkboxes.
|
||||
foreach (element_children($element) as $key) {
|
||||
$element[$key]['#return_value'] = check_plain($element[$key]['#return_value']);
|
||||
$element[$key]['#name'] = $element['#name'] . '[' . $element[$key]['#return_value'] . ']';
|
||||
}
|
||||
|
||||
foreach ($default_value as $key => $val) {
|
||||
$element[$key]['#default_value'] = $val;
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* FAPI process function to rename IDs attached to checkboxes and radios.
|
||||
*/
|
||||
|
@@ -202,12 +202,16 @@ function webform_expand_time($element) {
|
||||
$element['hour'] = array(
|
||||
'#prefix' => '',
|
||||
'#type' => 'select',
|
||||
'#title' => t('Hour'),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $default_values['hour'],
|
||||
'#options' => $hours,
|
||||
);
|
||||
$element['minute'] = array(
|
||||
'#prefix' => ':',
|
||||
'#type' => 'select',
|
||||
'#title' => t('Minute'),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $default_values['minute'],
|
||||
'#options' => $minutes,
|
||||
);
|
||||
@@ -233,8 +237,8 @@ function webform_expand_time($element) {
|
||||
function theme_webform_time($variables) {
|
||||
$element = $variables['element'];
|
||||
|
||||
$element['hour']['#attributes']['class'] = array('hour');
|
||||
$element['minute']['#attributes']['class'] = array('minute');
|
||||
$element['hour']['#attributes']['class'][] = 'hour';
|
||||
$element['minute']['#attributes']['class'][] = 'minute';
|
||||
|
||||
// Add error classes to all items within the element.
|
||||
if (form_get_error($element)) {
|
||||
|
@@ -220,17 +220,10 @@ function theme_webform_admin_settings($variables) {
|
||||
* Menu callback for admin/content/webform. Displays all webforms on the site.
|
||||
*/
|
||||
function webform_admin_content() {
|
||||
$webform_types = webform_variable_get('webform_node_types');
|
||||
|
||||
$nodes = array();
|
||||
if ($webform_types) {
|
||||
$nodes = db_select('node', 'n')
|
||||
->fields('n')
|
||||
->condition('n.type', $webform_types, 'IN')
|
||||
->execute()
|
||||
->fetchAllAssoc('nid');
|
||||
}
|
||||
|
||||
$query = db_select('webform', 'w');
|
||||
$query->join('node', 'n', 'w.nid = n.nid');
|
||||
$query->fields('n');
|
||||
$nodes = $query->execute()->fetchAllAssoc('nid');
|
||||
return theme('webform_admin_content', array('nodes' => $nodes));
|
||||
}
|
||||
|
||||
@@ -262,7 +255,7 @@ function theme_webform_admin_content($variables) {
|
||||
$header = array(
|
||||
t('Title'),
|
||||
array('data' => t('View'), 'colspan' => '4'),
|
||||
array('data' => t('Operations'), 'colspan' => '2')
|
||||
array('data' => t('Operations'), 'colspan' => '3')
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
@@ -274,6 +267,7 @@ function theme_webform_admin_content($variables) {
|
||||
l(t('Table'), 'node/' . $node->nid . '/webform-results/table'),
|
||||
l(t('Download'), 'node/' . $node->nid . '/webform-results/download'),
|
||||
node_access('update', $node) ? l(t('Edit'), 'node/' . $node->nid . '/edit') : '',
|
||||
node_access('update', $node) ? l(t('Components'), 'node/' . $node->nid . '/webform') : '',
|
||||
user_access('delete all webform submissions') ? l(t('Clear'), 'node/' . $node->nid . '/webform-results/clear') : '',
|
||||
);
|
||||
}
|
||||
|
@@ -135,7 +135,8 @@ function webform_components_form($form, $form_state, $node) {
|
||||
'#submit' => array('webform_components_form_add_submit'),
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#weight' => 45,
|
||||
@@ -293,7 +294,7 @@ function webform_components_form_validate($form, &$form_state) {
|
||||
$items = array();
|
||||
foreach ($duplicates as $form_key => $cids) {
|
||||
foreach ($cids as $cid) {
|
||||
$items[] = $form['#node']->webform['components'][$cid]['name'];
|
||||
$items[] = _webform_filter_xss($form['#node']->webform['components'][$cid]['name']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,12 +600,20 @@ function webform_component_edit_form($form, $form_state, $node, $component, $clo
|
||||
$form = array_merge($form, $additional_form_elements);
|
||||
|
||||
// Add the submit button.
|
||||
$form['submit'] = array(
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save component'),
|
||||
'#weight' => 50,
|
||||
);
|
||||
|
||||
// Remove fieldsets without any child form controls.
|
||||
foreach ($form as $group_key => $group) {
|
||||
if (isset($group['#type']) && $group['#type'] === 'fieldset' && !element_children($group)) {
|
||||
unset($form[$group_key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -671,7 +680,7 @@ function webform_component_edit_form_submit($form, &$form_state) {
|
||||
|
||||
// Clear the entity cache if Entity Cache module is installed.
|
||||
if (module_exists('entitycache')) {
|
||||
cache_clear_all($node->nid, 'cache_entity_node');
|
||||
entity_get_controller('node')->resetCache(array($node->nid));
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array('node/' . $node->nid . '/webform/components', isset($cid) ? array('query' => array('cid' => $cid)) : array());
|
||||
@@ -726,7 +735,7 @@ function webform_component_delete_form_submit($form, &$form_state) {
|
||||
|
||||
// Clear the entity cache if Entity Cache module is installed.
|
||||
if (module_exists('entitycache')) {
|
||||
cache_clear_all($node->nid, 'cache_entity_node');
|
||||
entity_get_controller('node')->resetCache(array($node->nid));
|
||||
}
|
||||
|
||||
$form_state['redirect'] = 'node/' . $node->nid . '/webform/components';
|
||||
@@ -1061,7 +1070,9 @@ function webform_component_parent_keys($node, $component) {
|
||||
* Populate a component with the defaults for that type.
|
||||
*/
|
||||
function webform_component_defaults(&$component) {
|
||||
if ($defaults = webform_component_invoke($component['type'], 'defaults')) {
|
||||
$defaults = webform_component_invoke($component['type'], 'defaults');
|
||||
drupal_alter('webform_component_defaults', $defaults, $component['type']);
|
||||
if (!empty($defaults)) {
|
||||
foreach ($defaults as $key => $default) {
|
||||
if (!isset($component[$key])) {
|
||||
$component[$key] = $default;
|
||||
|
@@ -25,9 +25,9 @@ function webform_emails_form($form, $form_state, $node) {
|
||||
);
|
||||
|
||||
foreach ($node->webform['emails'] as $eid => $email) {
|
||||
$email_addresses = array_filter(explode(',', check_plain($email['email'])));
|
||||
$email_addresses = array_filter(explode(',', $email['email']));
|
||||
foreach ($email_addresses as $key => $email_address) {
|
||||
$email_addresses[$key] = webform_format_email_address($email_address, NULL, $node, NULL, FALSE);
|
||||
$email_addresses[$key] = check_plain(webform_format_email_address($email_address, NULL, $node, NULL, FALSE));
|
||||
}
|
||||
|
||||
$form['emails'][$eid]['email'] = array(
|
||||
@@ -134,12 +134,13 @@ function theme_webform_email_add_form($variables) {
|
||||
|
||||
// Add a default value to the custom e-mail textfield.
|
||||
$form['email_custom']['#attributes']['rel'] = t('email@example.com');
|
||||
$form['email_custom']['#attributes']['class'] = array('webform-set-active', 'webform-default-value');
|
||||
$form['email_custom']['#attributes']['class'][] = 'webform-set-active';
|
||||
$form['email_custom']['#attributes']['class'][] = 'webform-default-value';
|
||||
$form['email_option']['custom']['#theme_wrappers'] = array('webform_inline_radio');
|
||||
$form['email_option']['custom']['#inline_element'] = drupal_render($form['email_custom']);
|
||||
|
||||
// Render the component value.
|
||||
$form['email_component']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['email_component']['#attributes']['class'][] = 'webform-set-active';
|
||||
$form['email_option']['component']['#theme_wrappers'] = array('webform_inline_radio');
|
||||
$form['email_option']['component']['#inline_element'] = drupal_render($form['email_component']);
|
||||
|
||||
@@ -309,7 +310,8 @@ function webform_email_edit_form($form, $form_state, $node, $email = array()) {
|
||||
);
|
||||
|
||||
// Add the submit button.
|
||||
$form['submit'] = array(
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save e-mail settings'),
|
||||
'#weight' => 20,
|
||||
@@ -329,7 +331,7 @@ function theme_webform_email_edit_form($variables) {
|
||||
// Loop through fields, rendering them into radio button options.
|
||||
foreach (array('email', 'subject', 'from_address', 'from_name') as $field) {
|
||||
foreach (array('custom', 'component') as $option) {
|
||||
$form[$field . '_' . $option]['#attributes']['class'] = array('webform-set-active');
|
||||
$form[$field . '_' . $option]['#attributes']['class'][] = 'webform-set-active';
|
||||
$form[$field . '_option'][$option]['#theme_wrappers'] = array('webform_inline_radio');
|
||||
$form[$field . '_option'][$option]['#inline_element'] = drupal_render($form[$field . '_' . $option]);
|
||||
}
|
||||
@@ -451,7 +453,7 @@ function webform_email_edit_form_submit($form, &$form_state) {
|
||||
|
||||
// Clear the entity cache if Entity Cache module is installed.
|
||||
if (module_exists('entitycache')) {
|
||||
cache_clear_all($node->nid, 'cache_entity_node');
|
||||
entity_get_controller('node')->resetCache(array($node->nid));
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array('node/' . $node->nid . '/webform/emails');
|
||||
@@ -499,7 +501,7 @@ function webform_email_delete_form_submit($form, &$form_state) {
|
||||
|
||||
// Clear the entity cache if Entity Cache module is installed.
|
||||
if (module_exists('entitycache')) {
|
||||
cache_clear_all($node->nid, 'cache_entity_node');
|
||||
entity_get_controller('node')->resetCache(array($node->nid));
|
||||
}
|
||||
|
||||
$form_state['redirect'] = 'node/' . $node->nid . '/webform/emails';
|
||||
|
@@ -355,7 +355,7 @@ function webform_configure_form_submit_save($form, &$form_state) {
|
||||
function theme_webform_advanced_redirection_form($variables) {
|
||||
$form = $variables['form'];
|
||||
// Add special class for setting the active radio button.
|
||||
$form['redirect_url']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['redirect_url']['#attributes']['class'][] = 'webform-set-active';
|
||||
|
||||
// Remove title and description for Redirect URL field.
|
||||
$form['redirect_url']['#title'] = NULL;
|
||||
@@ -375,8 +375,8 @@ function theme_webform_advanced_redirection_form($variables) {
|
||||
*/
|
||||
function theme_webform_advanced_submit_limit_form($variables) {
|
||||
$form = $variables['form'];
|
||||
$form['submit_limit']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['submit_interval']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['submit_limit']['#attributes']['class'][] = 'webform-set-active';
|
||||
$form['submit_interval']['#attributes']['class'][] = 'webform-set-active';
|
||||
// Remove div wrappers around limit options.
|
||||
$form['submit_limit']['#theme_wrappers'] = array();
|
||||
$form['submit_interval']['#theme_wrappers'] = array();
|
||||
@@ -398,8 +398,8 @@ function theme_webform_advanced_submit_limit_form($variables) {
|
||||
*/
|
||||
function theme_webform_advanced_total_submit_limit_form($variables) {
|
||||
$form = $variables['form'];
|
||||
$form['total_submit_limit']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['total_submit_interval']['#attributes']['class'] = array('webform-set-active');
|
||||
$form['total_submit_limit']['#attributes']['class'][] = 'webform-set-active';
|
||||
$form['total_submit_interval']['#attributes']['class'][] = 'webform-set-active';
|
||||
// Remove div wrappers around limit options.
|
||||
$form['total_submit_limit']['#theme_wrappers'] = array();
|
||||
$form['total_submit_interval']['#theme_wrappers'] = array();
|
||||
|
@@ -29,7 +29,6 @@ function webform_results_submissions($node, $user_filter, $pager_count) {
|
||||
drupal_set_title(t('Your submissions'));
|
||||
webform_disable_page_cache();
|
||||
}
|
||||
webform_set_breadcrumb($node);
|
||||
$submissions = webform_get_submissions(array('nid' => $node->nid, 'uid' => $user->uid), $header, $pager_count);
|
||||
$count = webform_get_submission_count($node->nid, $user->uid);
|
||||
}
|
||||
@@ -585,14 +584,14 @@ function theme_webform_results_download_range($variables) {
|
||||
}
|
||||
|
||||
// Render latest x submissions option.
|
||||
$element['latest']['#attributes']['class'] = array('webform-set-active');
|
||||
$element['latest']['#attributes']['class'][] = 'webform-set-active';
|
||||
$element['range_type']['latest']['#theme_wrappers'] = array('webform_inline_radio');
|
||||
$element['range_type']['latest']['#inline_element'] = t('Only the latest !number submissions', array('!number' => drupal_render($element['latest'])));
|
||||
$element['range_type']['latest']['#title'] = NULL;
|
||||
|
||||
// Render Start-End submissions option.
|
||||
$element['start']['#attributes']['class'] = array('webform-set-active');
|
||||
$element['end']['#attributes']['class'] = array('webform-set-active');
|
||||
$element['start']['#attributes']['class'][] = 'webform-set-active';
|
||||
$element['end']['#attributes']['class'][] = 'webform-set-active';
|
||||
$element['range_type']['range']['#theme_wrappers'] = array('webform_inline_radio');
|
||||
$element['range_type']['range']['#inline_element'] = t('All submissions starting from: !start and optionally to: !end', array('!start' => drupal_render($element['start']), '!end' => drupal_render($element['end'])));
|
||||
$element['range_type']['range']['#title'] = NULL;
|
||||
@@ -730,6 +729,10 @@ function webform_results_export($node, $format = 'delimited', $options = array()
|
||||
// Let each component determine its headers.
|
||||
if (webform_component_feature($component['type'], 'csv')) {
|
||||
$component_header = (array) webform_component_invoke($component['type'], 'csv_headers', $component, $options);
|
||||
// Allow modules to modify the component CSV header.
|
||||
drupal_alter('webform_csv_header', $component_header, $component);
|
||||
|
||||
// Merge component CSV header to overall CSV header
|
||||
$header[0] = array_merge($header[0], (array) $component_header[0]);
|
||||
$header[1] = array_merge($header[1], (array) $component_header[1]);
|
||||
$header[2] = array_merge($header[2], (array) $component_header[2]);
|
||||
@@ -751,6 +754,7 @@ function webform_results_export($node, $format = 'delimited', $options = array()
|
||||
|
||||
// Generate a row for each submission.
|
||||
$row_count = 0;
|
||||
$sid = 0;
|
||||
foreach ($submissions as $sid => $submission) {
|
||||
$row_count++;
|
||||
|
||||
@@ -784,6 +788,10 @@ function webform_results_export($node, $format = 'delimited', $options = array()
|
||||
$raw_data = isset($submission->data[$cid]['value']) ? $submission->data[$cid]['value'] : NULL;
|
||||
if (webform_component_feature($component['type'], 'csv')) {
|
||||
$data = webform_component_invoke($component['type'], 'csv_data', $component, $options, $raw_data);
|
||||
|
||||
// Allow modules to modify the CSV data.
|
||||
drupal_alter('webform_csv_data', $data, $component, $submission);
|
||||
|
||||
if (is_array($data)) {
|
||||
$row = array_merge($row, array_values($data));
|
||||
}
|
||||
|
@@ -131,10 +131,10 @@ function webform_submission_insert($node, $submission) {
|
||||
/**
|
||||
* Delete a single submission.
|
||||
*
|
||||
* @param $nid
|
||||
* ID of node for which this webform was submitted.
|
||||
* @param $sid
|
||||
* ID of submission to be deleted (from webform_submitted_data).
|
||||
* @param $node
|
||||
* The node object containing the current webform.
|
||||
* @param $submission
|
||||
* The webform submission object to be deleted from the database.
|
||||
*/
|
||||
function webform_submission_delete($node, $submission) {
|
||||
// Iterate through all components and let each do cleanup if necessary.
|
||||
@@ -456,14 +456,14 @@ function webform_submission_resend($form, $form_state, $node, $submission) {
|
||||
'#markup' => implode('<br />', $email_addresses),
|
||||
);
|
||||
if (!$valid_email) {
|
||||
$form['emails'][$eid]['email']['#value'] .= ' (' . t('empty') . ')';
|
||||
$form['emails'][$eid]['email']['#markup'] .= ' (' . t('empty') . ')';
|
||||
}
|
||||
$form['emails'][$eid]['subject'] = array(
|
||||
'#markup' => check_plain(webform_format_email_subject($email['subject'], $node, $submission)),
|
||||
);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['resend'] = array(
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Resend e-mails'),
|
||||
);
|
||||
@@ -801,6 +801,7 @@ function _webform_submission_user_limit_check($node) {
|
||||
|
||||
// Retrieve submission data for this IP address or username from the database.
|
||||
$query = db_select('webform_submissions')
|
||||
->addTag('webform_submission_user_limit_check')
|
||||
->condition('nid', $node->nid)
|
||||
->condition('is_draft', 0);
|
||||
|
||||
@@ -865,6 +866,7 @@ function _webform_submission_total_limit_check($node) {
|
||||
|
||||
// Retrieve submission data from the database.
|
||||
$query = db_select('webform_submissions')
|
||||
->addTag('webform_submission_total_limit_check')
|
||||
->condition('nid', $node->nid)
|
||||
->condition('is_draft', 0);
|
||||
|
||||
|
@@ -48,7 +48,7 @@ Drupal.webform.selectOptionsLoad = function(result) {
|
||||
$('#' + result.elementId).val(result.options).attr('readonly', 'readonly');
|
||||
}
|
||||
else {
|
||||
$('#' + result.elementId).attr('readonly', '');
|
||||
$('#' + result.elementId).removeAttr('readonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,9 +50,9 @@ Drupal.webform.datepicker = function(context) {
|
||||
maxDate: endDate,
|
||||
onSelect: function(dateText, inst) {
|
||||
var date = dateText.split('-');
|
||||
$webformDatepicker.find('select.year, input.year').val(+date[0]);
|
||||
$webformDatepicker.find('select.month').val(+date[1]);
|
||||
$webformDatepicker.find('select.day').val(+date[2]);
|
||||
$webformDatepicker.find('select.year, input.year').val(+date[0]).trigger('change');
|
||||
$webformDatepicker.find('select.month').val(+date[1]).trigger('change');
|
||||
$webformDatepicker.find('select.day').val(+date[2]).trigger('change');
|
||||
},
|
||||
beforeShow: function(input, inst) {
|
||||
// Get the select list values.
|
||||
|
@@ -30,7 +30,7 @@ class webform_handler_field_form_body extends views_handler_field {
|
||||
|
||||
if (node_access('view', $node)) {
|
||||
// Populate $node->content['webform'] by reference.
|
||||
webform_node_view($node, 'full');
|
||||
webform_node_view($node, 'form');
|
||||
$form_body = isset($node->content['webform']) ? drupal_render($node->content['webform']) : NULL;
|
||||
}
|
||||
else {
|
||||
|
@@ -52,7 +52,7 @@ class webform_handler_field_submission_count extends views_handler_field {
|
||||
elseif ($this->count_type == 'users') {
|
||||
$output = db_select('webform_submissions')
|
||||
->condition('uid', $values->{$this->aliases['uid']})
|
||||
->countQuery->execute()->fetchField();
|
||||
->countQuery()->execute()->fetchField();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
@@ -301,6 +301,28 @@ function hook_webform_component_delete($component) {
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter a Webform submission's header when exported.
|
||||
*/
|
||||
function hook_webform_csv_header_alter(&$header, $component) {
|
||||
// Use the machine name for component headers, but only for the webform
|
||||
// with node 5 and components that are text fields.
|
||||
if ($component['nid'] == 5 && $component['type'] == 'textfield') {
|
||||
$header[2] = $component['form_key'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter a Webform submission's data when exported.
|
||||
*/
|
||||
function hook_webform_csv_data_alter(&$data, $component, $submission) {
|
||||
// If a value of a field was left blank, use the value from another
|
||||
// field.
|
||||
if ($component['cid'] == 1 && empty($data)) {
|
||||
$data = $submission->data[2]['value'][0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define components to Webform.
|
||||
*
|
||||
@@ -431,6 +453,36 @@ function hook_webform_component_info_alter(&$components) {
|
||||
$components['textarea']['label'] = t('Text box');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the list of Webform component default values.
|
||||
*
|
||||
* @param $defaults
|
||||
* A list of component defaults as defined by _webform_defaults_COMPONENT().
|
||||
* @param $type
|
||||
* The component type whose defaults are being provided.
|
||||
*
|
||||
* @see _webform_defaults_component()
|
||||
*/
|
||||
function hook_webform_component_defaults_alter(&$defaults, $type) {
|
||||
// Alter a default for all component types.
|
||||
$defaults['required'] = 1;
|
||||
|
||||
// Add a default for a new field added via hook_form_alter() or
|
||||
// hook_form_FORM_ID_alter() for all component types.
|
||||
$defaults['extra']['added_field'] = t('Added default value');
|
||||
|
||||
// Add or alter defaults for specific component types:
|
||||
switch ($type) {
|
||||
case 'select':
|
||||
$defaults['extra']['optrand'] = 1;
|
||||
break;
|
||||
|
||||
case 'textfield':
|
||||
case 'textarea':
|
||||
$defaults['extra']['another_added_field'] = t('Another added default value');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter access to a Webform submission.
|
||||
*
|
||||
@@ -492,6 +544,26 @@ function hook_webform_results_access($node, $account) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a user has access to clear the results of a webform.
|
||||
*
|
||||
* Access via this hook is in addition (adds permission) to the standard
|
||||
* webform access (delete all webform submissions).
|
||||
*
|
||||
* @see webform_results_clear_access().
|
||||
*
|
||||
* @param $node object
|
||||
* The Webform node to check access on.
|
||||
* @param $account object
|
||||
* The user account to check access on.
|
||||
* @return boolean
|
||||
* TRUE or FALSE if the user can access the webform results.
|
||||
*/
|
||||
function hook_webform_results_clear_access($node, $account) {
|
||||
return user_access('my additional access', $account);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of files associated with the component.
|
||||
*
|
||||
@@ -718,10 +790,9 @@ function _webform_submit_component($component, $value) {
|
||||
*/
|
||||
function _webform_delete_component($component, $value) {
|
||||
// Delete corresponding files when a submission is deleted.
|
||||
$filedata = unserialize($value['0']);
|
||||
if (isset($filedata['filepath']) && is_file($filedata['filepath'])) {
|
||||
unlink($filedata['filepath']);
|
||||
db_query("DELETE FROM {files} WHERE filepath = '%s'", $filedata['filepath']);
|
||||
if (!empty($value[0]) && ($file = webform_get_file($value[0]))) {
|
||||
file_usage_delete($file, 'webform');
|
||||
file_delete($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,9 +24,9 @@ files[] = tests/permissions.test
|
||||
files[] = tests/submission.test
|
||||
files[] = tests/webform.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-05-29
|
||||
version = "7.x-3.19"
|
||||
; Information added by Drupal.org packaging script on 2015-04-02
|
||||
version = "7.x-3.24"
|
||||
core = "7.x"
|
||||
project = "webform"
|
||||
datestamp = "1369860079"
|
||||
datestamp = "1427956663"
|
||||
|
||||
|
@@ -369,6 +369,7 @@ function webform_schema() {
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'sid_nid' => array('sid', 'nid'),
|
||||
'data' => array(array('data', 64)),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -434,7 +435,9 @@ function webform_install() {
|
||||
);
|
||||
$webform_type = node_type_set_defaults($webform_type);
|
||||
node_type_save($webform_type);
|
||||
node_add_body_field($webform_type);
|
||||
if (variable_get('webform_install_add_body_field', TRUE)) {
|
||||
node_add_body_field($webform_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +448,7 @@ function webform_uninstall() {
|
||||
// Unset webform variables.
|
||||
variable_del('webform_node_types');
|
||||
variable_del('webform_node_types_primary');
|
||||
variable_del('webform_disabled_components');
|
||||
variable_del('webform_use_cookies');
|
||||
variable_del('webform_default_from_address');
|
||||
variable_del('webform_default_from_name');
|
||||
@@ -454,6 +458,11 @@ function webform_uninstall() {
|
||||
variable_del('webform_csv_delimiter');
|
||||
variable_del('webform_allowed_tags');
|
||||
variable_del('webform_blocks');
|
||||
variable_del('webform_search_index');
|
||||
variable_del('webform_email_address_format');
|
||||
variable_del('webform_export_format');
|
||||
variable_del('webform_submission_access_control');
|
||||
variable_del('webform_update_batch_size');
|
||||
|
||||
$component_list = array();
|
||||
$path = drupal_get_path('module', 'webform') . '/components';
|
||||
@@ -843,3 +852,10 @@ function webform_update_7321() {
|
||||
_webform_delete_file(NULL, array($fid));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index on {webform_submitted_data}.data.
|
||||
*/
|
||||
function webform_update_7322() {
|
||||
db_add_index('webform_submitted_data', 'data', array(array('data', 64)));
|
||||
}
|
||||
|
@@ -61,10 +61,6 @@ function webform_help($section = 'admin/help#webform', $arg = NULL) {
|
||||
<p>Help on adding and configuring the components will be shown after you add your first component.</p>
|
||||
", array('!webform-types-message' => $types_message, '!create-content' => url('node/add'), '!types' => $types));
|
||||
break;
|
||||
case 'node/%/webform/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;
|
||||
case 'node/%/submission/%/resend':
|
||||
$output .= '<p>' . t('This form may be used to resend e-mails configured for this webform. Check the e-mails that need to be sent and click <em>Resend e-mails</em> to send these e-mails again.') . '</p>';
|
||||
break;
|
||||
@@ -155,7 +151,6 @@ function webform_menu() {
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
$items['node/%webform_menu/webform/emails/%webform_menu_email'] = array(
|
||||
'title' => 'Edit e-mail settings',
|
||||
'load arguments' => array(1),
|
||||
'page arguments' => array('webform_email_edit_form', 1, 4),
|
||||
'access callback' => 'node_access',
|
||||
@@ -164,7 +159,6 @@ function webform_menu() {
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
$items['node/%webform_menu/webform/emails/%webform_menu_email/delete'] = array(
|
||||
'title' => 'Delete e-mail settings',
|
||||
'load arguments' => array(1),
|
||||
'page arguments' => array('webform_email_delete_form', 1, 4),
|
||||
'access callback' => 'node_access',
|
||||
@@ -948,6 +942,11 @@ function webform_webform_submission_presave($node, &$submission) {
|
||||
if ($component['type'] == 'file') {
|
||||
$has_file_components = TRUE;
|
||||
if (!empty($submission->data[$cid]['value'])) {
|
||||
foreach ($submission->data[$cid]['value'] as $key => $value) {
|
||||
if (empty($value)) {
|
||||
unset($submission->data[$cid]['value'][$key]);
|
||||
}
|
||||
}
|
||||
$new_fids = array_merge($new_fids, $submission->data[$cid]['value']);
|
||||
}
|
||||
}
|
||||
@@ -1009,6 +1008,7 @@ function webform_webform_submission_render_alter(&$renderable) {
|
||||
// are being displayed.
|
||||
$node = $renderable['#node'];
|
||||
$is_admin = webform_results_access($node);
|
||||
module_load_include('inc', 'webform', 'includes/webform.components');
|
||||
if (empty($renderable['#email']) && !$is_admin) {
|
||||
// Find and hide the display of all hidden components.
|
||||
foreach ($node->webform['components'] as $cid => $component) {
|
||||
@@ -1134,6 +1134,11 @@ function webform_node_insert($node) {
|
||||
foreach (array_filter($node->webform['roles']) as $rid) {
|
||||
db_insert('webform_roles')->fields(array('nid' => $node->nid, 'rid' => $rid))->execute();
|
||||
}
|
||||
|
||||
// Flush the block cache if creating a block.
|
||||
if ($node->webform['block']) {
|
||||
block_flush_caches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1220,10 +1225,15 @@ function webform_node_update($node) {
|
||||
db_insert('webform_roles')->fields(array('nid' => $node->nid, 'rid' => $rid))->execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Flush the block cache if block settings have been changed.
|
||||
if ($node->webform['block'] != $original->webform['block']) {
|
||||
block_flush_caches();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_delete().
|
||||
* Implements hook_node_delete().
|
||||
*/
|
||||
function webform_node_delete($node) {
|
||||
if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
|
||||
@@ -1369,24 +1379,6 @@ function webform_node_load($nodes, $types) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_link().
|
||||
* Always add a "view form" link.
|
||||
*/
|
||||
function webform_link($type, $node = NULL, $teaser = FALSE) {
|
||||
$links = array();
|
||||
if (isset($node->type) && $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' => array('read-more'))
|
||||
);
|
||||
}
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
@@ -1442,6 +1434,13 @@ function webform_node_view($node, $view_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the webform is not set to display in this view mode, return early.
|
||||
// View mode of 'form' is exempted to allow blocks and views to force display.
|
||||
$extra_fields = field_extra_fields_get_display('node', $node->type, $view_mode);
|
||||
if ($view_mode != 'form' && empty($extra_fields['webform']['visible'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$info = array();
|
||||
$submission = array();
|
||||
$submission_count = 0;
|
||||
@@ -1529,8 +1528,18 @@ function webform_node_view($node, $view_mode) {
|
||||
}
|
||||
}
|
||||
|
||||
// Render the form and generate the output.
|
||||
$form = !empty($node->webform['components']) ? drupal_get_form('webform_client_form_' . $node->nid, $node, $submission, $is_draft) : '';
|
||||
// Avoid building the same form twice on the same page request (which can
|
||||
// happen if the webform is displayed in a panel or block) because this
|
||||
// causes multistep forms to build incorrectly the second time.
|
||||
$cached_forms = &drupal_static(__FUNCTION__, array());
|
||||
if (isset($cached_forms[$node->nid])) {
|
||||
$form = $cached_forms[$node->nid];
|
||||
}
|
||||
// If this is the first time, generate the form array.
|
||||
else {
|
||||
$form = drupal_get_form('webform_client_form_' . $node->nid, $node, $submission, $is_draft);
|
||||
$cached_forms[$node->nid] = $form;
|
||||
}
|
||||
|
||||
// Remove the surrounding <form> tag if this is a preview.
|
||||
if (!empty($node->in_preview)) {
|
||||
@@ -1634,6 +1643,7 @@ function theme_webform_view_messages($variables) {
|
||||
else {
|
||||
// The user must be some other role to submit.
|
||||
$message = t('You do not have permission to view this form.');
|
||||
$type = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1741,8 +1751,6 @@ function webform_block_view($delta = '') {
|
||||
// This is a webform node block.
|
||||
$node->webform_block = TRUE;
|
||||
|
||||
// Use the node title for the block title.
|
||||
$subject = $node->title;
|
||||
|
||||
// If not displaying pages in the block, set the #action property on the form.
|
||||
if ($settings['pages_block']) {
|
||||
@@ -1755,8 +1763,8 @@ function webform_block_view($delta = '') {
|
||||
|
||||
// Generate the content of the block based on display settings.
|
||||
if ($settings['display'] == 'form') {
|
||||
webform_node_view($node, 'full');
|
||||
$content = $node->content['webform'];
|
||||
webform_node_view($node, 'form');
|
||||
$content = isset($node->content['webform']) ? $node->content['webform'] : array();
|
||||
}
|
||||
else {
|
||||
$teaser = ($settings['display'] == 'teaser') ? 'teaser' : 'full';
|
||||
@@ -1768,11 +1776,11 @@ function webform_block_view($delta = '') {
|
||||
$content['#contextual_links']['node'] = array('node', array($node->nid));
|
||||
}
|
||||
|
||||
// Create the block.
|
||||
// Create the block, using the node title for the block title.
|
||||
// Note that we render the content immediately here rather than passing back
|
||||
// a renderable so that if the block is empty it is hidden.
|
||||
$block = array(
|
||||
'subject' => $subject,
|
||||
'subject' => check_plain($node->title),
|
||||
'content' => drupal_render($content),
|
||||
);
|
||||
return $block;
|
||||
@@ -1934,8 +1942,8 @@ function webform_client_form($form, &$form_state, $node, $submission, $is_draft
|
||||
$component_value = isset($form_state['values']['submitted'][$cid]) ? $form_state['values']['submitted'][$cid] : NULL;
|
||||
if ($filter == FALSE || _webform_client_form_rule_check($node, $component, $page_num, $form_state)) {
|
||||
if ($component['type'] == 'pagebreak') {
|
||||
$next_page_labels[$component['page_num'] - 1] = !empty($component['extra']['next_page_label']) ? $component['extra']['next_page_label'] : t('Next Page >');
|
||||
$prev_page_labels[$component['page_num']] = !empty($component['extra']['prev_page_label']) ? $component['extra']['prev_page_label'] : t('< Previous Page');
|
||||
$next_page_labels[$component['page_num'] - 1] = !empty($component['extra']['next_page_label']) ? t($component['extra']['next_page_label']) : t('Next Page >');
|
||||
$prev_page_labels[$component['page_num']] = !empty($component['extra']['prev_page_label']) ? t($component['extra']['prev_page_label']) : t('< Previous Page');
|
||||
}
|
||||
_webform_client_form_add_component($node, $component, $component_value, $form['submitted'], $form, $form_state, $submission, 'form', $page_num, $filter);
|
||||
}
|
||||
@@ -1948,7 +1956,7 @@ function webform_client_form($form, &$form_state, $node, $submission, $is_draft
|
||||
);
|
||||
$form['details']['sid'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => isset($submission->sid) ? $submission->sid : '',
|
||||
'#value' => isset($submission->sid) ? $submission->sid : NULL,
|
||||
);
|
||||
$form['details']['uid'] = array(
|
||||
'#type' => 'value',
|
||||
@@ -2092,11 +2100,6 @@ function _webform_client_form_rule_check($node, $component, $page_num, $form_sta
|
||||
}
|
||||
}
|
||||
|
||||
// Private component?
|
||||
if ($component['extra']['private']) {
|
||||
$show_component = webform_results_access($node);
|
||||
}
|
||||
|
||||
return $show_component;
|
||||
}
|
||||
|
||||
@@ -2132,12 +2135,16 @@ function _webform_client_form_rule_check($node, $component, $page_num, $form_sta
|
||||
*/
|
||||
function _webform_client_form_add_component($node, $component, $component_value, &$parent_fieldset, &$form, $form_state, $submission, $format = 'form', $page_num = 0, $filter = TRUE) {
|
||||
$cid = $component['cid'];
|
||||
$component_access = empty($component['extra']['private']) || webform_results_access($node);
|
||||
|
||||
// Load with submission information if necessary.
|
||||
if ($format != 'form') {
|
||||
// This component is display only.
|
||||
$data = empty($submission->data[$cid]['value']) ? NULL : $submission->data[$cid]['value'];
|
||||
if ($display_element = webform_component_invoke($component['type'], 'display', $component, $data, $format)) {
|
||||
// Set access based on the private property.
|
||||
$element['#access'] = $component_access;
|
||||
|
||||
// Ensure the component is added as a property.
|
||||
$display_element['#webform_component'] = $component;
|
||||
|
||||
@@ -2165,6 +2172,9 @@ function _webform_client_form_add_component($node, $component, $component_value,
|
||||
// Add this user-defined field to the form (with all the values that are always available).
|
||||
$data = isset($submission->data[$cid]['value']) ? $submission->data[$cid]['value'] : NULL;
|
||||
if ($element = webform_component_invoke($component['type'], 'render', $component, $data, $filter)) {
|
||||
// Set access based on the private property.
|
||||
$element['#access'] = $component_access;
|
||||
|
||||
// Ensure the component is added as a property.
|
||||
$element['#webform_component'] = $component;
|
||||
|
||||
@@ -2633,7 +2643,7 @@ function _webform_client_form_submit_flatten($node, $fieldset, $parent = 0) {
|
||||
*/
|
||||
function _webform_confirmation($node) {
|
||||
drupal_set_title($node->title);
|
||||
webform_set_breadcrumb($node);
|
||||
webform_set_breadcrumb($node, TRUE);
|
||||
$sid = isset($_GET['sid']) ? $_GET['sid'] : NULL;
|
||||
return theme(array('webform_confirmation_' . $node->nid, 'webform_confirmation'), array('node' => $node, 'sid' => $sid));
|
||||
}
|
||||
@@ -2715,6 +2725,12 @@ function theme_webform_element($variables) {
|
||||
}
|
||||
$output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n";
|
||||
|
||||
// If #title_display is none, set it to invisible instead - none only used if
|
||||
// we have no title at all to use.
|
||||
if ($element['#title_display'] == 'none') {
|
||||
$variables['element']['#title_display'] = 'invisible';
|
||||
$element['#title_display'] = 'invisible';
|
||||
}
|
||||
// If #title is not set, we don't display any label or required marker.
|
||||
if (!isset($element['#title'])) {
|
||||
$element['#title_display'] = 'none';
|
||||
@@ -2785,10 +2801,8 @@ function theme_webform_element_text($variables) {
|
||||
$value = implode("\n", $lines);
|
||||
}
|
||||
|
||||
// Add the value to the output.
|
||||
if ($value) {
|
||||
$output .= (strpos($value, "\n") === FALSE ? ' ' : "\n") . $value;
|
||||
}
|
||||
// Add the value to the output. Add a newline before the response if needed.
|
||||
$output .= (strpos($value, "\n") === FALSE ? ' ' : "\n") . $value;
|
||||
|
||||
// Indent fieldsets.
|
||||
if ($is_group) {
|
||||
@@ -2915,7 +2929,7 @@ function _webform_fetch_draft_sid($nid, $uid) {
|
||||
*/
|
||||
function _webform_filter_values($string, $node = NULL, $submission = NULL, $email = NULL, $strict = TRUE, $allow_anonymous = FALSE) {
|
||||
global $user;
|
||||
static $replacements;
|
||||
$replacements = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Don't do any filtering if the string is empty.
|
||||
if (strlen(trim($string)) == 0) {
|
||||
@@ -2939,7 +2953,7 @@ function _webform_filter_values($string, $node = NULL, $submission = NULL, $emai
|
||||
$format = isset($email['html']) && $email['html'] ? 'html' : 'text';
|
||||
|
||||
// Submission replacements.
|
||||
if (isset($submission) && !isset($replacements['email'][$format])) {
|
||||
if (isset($submission) && (!isset($replacements['email'][$format]) || (isset($replacements['unsafe']['%sid']) && $replacements['unsafe']['%sid'] != $submission->sid))) {
|
||||
module_load_include('inc', 'webform', 'includes/webform.components');
|
||||
|
||||
// Set the submission ID.
|
||||
@@ -2949,36 +2963,37 @@ function _webform_filter_values($string, $node = NULL, $submission = NULL, $emai
|
||||
$replacements['email'][$format] = array();
|
||||
|
||||
// Populate token values for each component.
|
||||
foreach ($submission->data as $cid => $value) {
|
||||
$component = $node->webform['components'][$cid];
|
||||
|
||||
foreach ($node->webform['components'] as $cid => $component) {
|
||||
// Find by form key.
|
||||
$parents = webform_component_parent_keys($node, $component);
|
||||
$form_key = implode('][', $parents);
|
||||
$display_element = webform_component_invoke($component['type'], 'display', $component, $value['value'], $format);
|
||||
if (isset($submission->data[$cid])) {
|
||||
$value = $submission->data[$cid];
|
||||
|
||||
// Ensure the component is added as a property.
|
||||
$display_element['#webform_component'] = $component;
|
||||
$display_element = webform_component_invoke($component['type'], 'display', $component, $value['value'], $format);
|
||||
|
||||
if (empty($display_element['#parents'])) {
|
||||
$display_element['#parents'] = array_merge(array('submitted'), $parents);
|
||||
// Ensure the component is added as a property.
|
||||
$display_element['#webform_component'] = $component;
|
||||
|
||||
if (empty($display_element['#parents'])) {
|
||||
$display_element['#parents'] = array_merge(array('submitted'), $parents);
|
||||
}
|
||||
if (empty($display_element['#id'])) {
|
||||
$display_element['#id'] = drupal_html_id('edit-' . implode('-', $display_element['#parents']));
|
||||
}
|
||||
$replacements['email'][$format]['%email[' . $form_key . ']'] = render($display_element);
|
||||
$display_element['#theme_wrappers'] = array(); // Remove label and wrappers.
|
||||
$replacements['email'][$format]['%value[' . $form_key . ']'] = render($display_element);
|
||||
}
|
||||
if (empty($display_element['#id'])) {
|
||||
$display_element['#id'] = drupal_html_id('edit-' . implode('-', $display_element['#parents']));
|
||||
else {
|
||||
// Provide an empty value for components without submitted data.
|
||||
$replacements['email'][$format]['%email[' . $form_key . ']'] = '';
|
||||
$replacements['email'][$format]['%value[' . $form_key . ']'] = '';
|
||||
}
|
||||
$replacements['email'][$format]['%email[' . $form_key . ']'] = render($display_element);
|
||||
$display_element['#theme_wrappers'] = array(); // Remove label and wrappers.
|
||||
$replacements['email'][$format]['%value[' . $form_key . ']'] = render($display_element);
|
||||
}
|
||||
|
||||
// Provide blanks for components in the webform but not in the submission.
|
||||
$missing_components = array_diff_key($node->webform['components'], $submission->data);
|
||||
foreach ($missing_components as $component) {
|
||||
$parents = webform_component_parent_keys($node, $component);
|
||||
$form_key = implode('][', $parents);
|
||||
$replacements['email'][$format]['%email[' . $form_key . ']'] = '';
|
||||
$replacements['email'][$format]['%value[' . $form_key . ']'] = '';
|
||||
}
|
||||
// Reverse the order of tokens so that nested tokens (ie. inside fieldsets)
|
||||
// come before their parents.
|
||||
$replacements['email'][$format] = array_reverse($replacements['email'][$format]);
|
||||
|
||||
// Submission edit URL.
|
||||
$replacements['unsafe']['%submission_url'] = url('node/' . $node->nid . '/submission/' . $submission->sid, array('absolute' => TRUE));
|
||||
@@ -2996,7 +3011,7 @@ function _webform_filter_values($string, $node = NULL, $submission = NULL, $emai
|
||||
'%post' => $_POST,
|
||||
),
|
||||
'unsafe' => array(
|
||||
'%cookie' => $_COOKIE,
|
||||
'%cookie' => isset($_COOKIE) ? $_COOKIE : array(),
|
||||
'%session' => isset($_SESSION) ? $_SESSION : array(),
|
||||
'%request' => $_REQUEST,
|
||||
'%server' => $_SERVER,
|
||||
@@ -3367,6 +3382,7 @@ function webform_format_email_address($address, $name, $node = NULL, $submission
|
||||
if ($encode) {
|
||||
$name = mime_header_encode($name);
|
||||
}
|
||||
$name = trim($name);
|
||||
return '"' . $name . '" <' . $address . '>';
|
||||
}
|
||||
else {
|
||||
@@ -3578,30 +3594,65 @@ function webform_disable_page_cache() {
|
||||
|
||||
/**
|
||||
* Set the necessary breadcrumb for the page we are on.
|
||||
*
|
||||
* @param object $node
|
||||
* The loaded webform node.
|
||||
* @param boolean|object $submission
|
||||
* The submission if the current page is viewing or dealing with a submission,
|
||||
* or TRUE to just include the webform node in the breadcrumbs (used for
|
||||
* the submission completion confirmation page), or NULL for no extra
|
||||
* processing
|
||||
*/
|
||||
function webform_set_breadcrumb($node, $submission = NULL) {
|
||||
$breadcrumb = drupal_get_breadcrumb();
|
||||
$node_path = "node/{$node->nid}";
|
||||
|
||||
if (isset($node)) {
|
||||
$webform_breadcrumb = array();
|
||||
$webform_breadcrumb[] = array_shift($breadcrumb);
|
||||
$webform_breadcrumb[] = l($node->title, 'node/' . $node->nid);
|
||||
if (isset($submission)) {
|
||||
$last_link = array_shift($breadcrumb);
|
||||
if (webform_results_access($node)) {
|
||||
$webform_breadcrumb[] = l(t('Webform results'), 'node/' . $node->nid . '/webform-results');
|
||||
}
|
||||
elseif (user_access('access own webform results', $account)) {
|
||||
$webform_breadcrumb[] = l(t('Submissions'), 'node/' . $node->nid . '/submissions');
|
||||
}
|
||||
if (isset($last_link)) {
|
||||
$webform_breadcrumb[] = $last_link;
|
||||
// Set the href of the current menu item to be the node's path. This has two
|
||||
// effects. The active trail will be to the node's prefered menu tree location,
|
||||
// expanding the menu as appropriate. And the breadcrumbs will be set as if
|
||||
// the current page were under the node's preferred location.
|
||||
// Note that menu_tree_set_path() could be used to set the path for the menu,
|
||||
// but it will not affect the breadcrumbs when the webform is not in the
|
||||
// default menu.
|
||||
menu_set_item(NULL, array('href' => $node_path) + menu_get_item());
|
||||
|
||||
if ($submission) {
|
||||
$breadcrumb = menu_get_active_breadcrumb();
|
||||
|
||||
// Append the node title (or its menu name), in case it isn't in the path already.
|
||||
$active_trail = menu_get_active_trail();
|
||||
$last_active = end($active_trail);
|
||||
$breadcrumb[] = $last_active['href'] === $node_path && !empty($last_active['in_active_trail'])
|
||||
? l($last_active['title'], $node_path, $last_active['localized_options'])
|
||||
: l($node->title, $node_path);
|
||||
|
||||
// Setting the current menu href will cause the submission title and current
|
||||
// tab (if not the default tab) to be added to the active path when the
|
||||
// webform is in the default location in the menu (node/NID). The title
|
||||
// is desirable, but the tab name (e.g. Edit or Delete) isn't.
|
||||
if (preg_match('/href=".*"/', end($breadcrumb), $matches)) {
|
||||
foreach ($breadcrumb as $index => $link) {
|
||||
if (stripos($link, $matches[0]) !== FALSE) {
|
||||
$breadcrumb = array_slice($breadcrumb, 0, $index + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$breadcrumb = $webform_breadcrumb;
|
||||
}
|
||||
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
// If the user is dealing with a submission, then the breadcrumb should
|
||||
// be fudged to allow them to return to a likely list of webforms.
|
||||
// Note that this isn't necessarily where they came from, but it's the
|
||||
// best guess available.
|
||||
if (is_object($submission)) {
|
||||
if (webform_results_access($node)) {
|
||||
$breadcrumb[] = l(t('Webform results'), $node_path . '/webform-results');
|
||||
}
|
||||
elseif (user_access('access own webform results')) {
|
||||
$breadcrumb[] = l(t('Submissions'), $node_path . '/submissions');
|
||||
}
|
||||
}
|
||||
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3775,23 +3826,31 @@ function webform_tt($name, $string, $langcode = NULL, $update = FALSE) {
|
||||
* Check if any available HTML mail handlers are available for Webform to use.
|
||||
*/
|
||||
function webform_email_html_capable() {
|
||||
// TODO: Right now we only support MIME Mail. Support others if available
|
||||
// through a hook?
|
||||
if (module_exists('mimemail')) {
|
||||
$mail_systems = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
|
||||
$enable = !isset($mail_systems['webform']) || $mail_systems['webform'] == 'MimeMailSystem';
|
||||
|
||||
// TODO: Right now we only support MIME Mail and HTML Mail. Support others
|
||||
// if available through a hook?
|
||||
$supported_html_modules = array(
|
||||
'mimemail' => 'MimeMailSystem',
|
||||
'htmlmail' => 'HTMLMailSystem',
|
||||
);
|
||||
foreach ($supported_html_modules as $mail_module => $mail_system_name) {
|
||||
if (module_exists($mail_module)) {
|
||||
$mail_systems = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
|
||||
if (isset($mail_systems['webform'])) {
|
||||
$enable = strpos($mail_systems['webform'], $mail_system_name) !== FALSE ? $mail_systems['webform'] : FALSE;
|
||||
}
|
||||
else {
|
||||
$enable = $mail_system_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($enable)) {
|
||||
// We assume that if a solution exists even if it's not specified we should
|
||||
// use it. Webform will specify if e-mails sent with the system are plain-
|
||||
// text or not when sending each e-mail.
|
||||
if ($enable) {
|
||||
$GLOBALS['conf']['mail_system']['webform'] = 'MimeMailSystem';
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
$GLOBALS['conf']['mail_system']['webform'] = $enable;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3829,10 +3888,11 @@ function webform_mollom_form_list() {
|
||||
return $forms;
|
||||
}
|
||||
|
||||
$result = db_select('node', 'n')
|
||||
->fields('n', array('nid', 'title'))
|
||||
->condition('n.type', $webform_types, 'IN')
|
||||
->execute();
|
||||
$query = db_select('webform', 'w');
|
||||
$query->innerJoin('node', 'n', 'n.nid = w.nid');
|
||||
$query->fields('n', array('nid', 'title'));
|
||||
$query->condition('n.type', $webform_types, 'IN');
|
||||
$result = $query->execute();
|
||||
|
||||
foreach ($result as $node) {
|
||||
$form_id = 'webform_client_form_' . $node->nid;
|
||||
|
Reference in New Issue
Block a user