function views_send_form_submit in Views Send 7
Submit handler for all steps of the Views Send multistep form.
3 string references to 'views_send_form_submit'
- views_send_config_form in ./
views_send.module - Multistep form callback for the "configure" step.
- views_send_confirm_form in ./
views_send.module - Multistep form callback for the "confirm" step. Allows the user to preview the whole message before sending it.
- views_send_form_alter in ./
views_send.module - Implements hook_form_alter().
File
- ./
views_send.module, line 585 - The Views Send module.
Code
function views_send_form_submit($form, &$form_state) {
$field = _views_send_get_field_selector($form_state['build_info']['args'][0]);
switch ($form_state['step']) {
case 'views_form_views_form':
$field_name = $field->options['id'];
$selection = array_filter($form_state['values'][$field_name]);
$form_state['selection'] = array_keys($selection);
$form_state['step'] = 'views_send_config_form';
$form_state['rebuild'] = TRUE;
break;
case 'views_send_config_form':
$display = $form['display']['#value'];
foreach ($form_state['values'] as $key => $value) {
$key = $key == 'format' ? 'views_send_message_format' : $key;
if (substr($key, 0, 11) == 'views_send_') {
if ($form_state['values']['views_send_remember']) {
variable_set($key . '_' . $display, $value);
}
else {
variable_del($key . '_' . $display);
}
}
}
$form_state['configuration'] = $form_state['values'];
$form_state['configuration']['views_send_attachments'] = array();
// If a file was uploaded, process it.
if (VIEWS_SEND_MIMEMAIL && user_access('attachments with views_send') && isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['views_send_attachments'])) {
// attempt to save the uploaded file
$dir = file_default_scheme() . '://views_send_attachments';
file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
$file_extensions = variable_get('views_send_attachment_valid_extensions', FALSE);
if ($file_extensions) {
$file_validators['file_validate_extensions'] = array();
$file_validators['file_validate_extensions'][0] = $file_extensions;
}
else {
$file_validators = array();
}
$file = file_save_upload('views_send_attachments', $file_validators, $dir);
// set error if file was not uploaded
if (!$file) {
//form_set_error('views_send_attachment', 'Error uploading file.');
}
else {
// set files to form_state, to process when form is submitted
// @todo: when we add a multifile formfield then loop through to add each file to attachments array
$form_state['configuration']['views_send_attachments'][] = (array) $file;
}
}
$form_state['step'] = 'views_send_confirm_form';
$form_state['rebuild'] = TRUE;
break;
case 'views_send_confirm_form':
// Queue the email for sending.
views_send_queue_mail($form_state['configuration'], $form_state['selection'], $field->view);
// Redirect.
$query = drupal_get_query_parameters($_GET, array(
'q',
));
$form_state['redirect'] = array(
$field->view
->get_url(),
array(
'query' => $query,
),
);
break;
}
}