function webform_protected_downloads_configuration_form_submit in Webform Protected Downloads 6
Same name and namespace in other branches
- 7 webform_protected_downloads.form.inc \webform_protected_downloads_configuration_form_submit()
Implementation of hook_submit().
Parameters
array $form :
array $form_state :
Return value
void
File
- ./
webform_protected_downloads.form.inc, line 239
Code
function webform_protected_downloads_configuration_form_submit($form, $form_state) {
$values = $form_state['values'];
$node = $values['node'];
foreach ($values['files'] as $key => $protected) {
$protected = (bool) $protected;
$private = $protected ? TRUE : _private_upload_is_file_private($node->files[$key]->filepath);
$node->files[$key]->private = $private;
$node->files[$key]->list = $protected ? FALSE : $node->files[$key]->list;
webform_protected_downloads_file_set_protected($node->nid, $node->files[$key]->fid, $protected);
}
webform_protected_downloads_set_configuration($node->nid, array(
'mail_field_cid' => $values['access_verification']['mail_field_cid'],
'mail_from' => $values['access_verification']['mail_from'],
'mail_subject' => $values['access_verification']['mail_subject'],
'mail_body' => $values['access_verification']['mail_body'],
'access_type' => $values['access_verification']['access_type'],
'expiration_download' => $values['access_verification']['expiration_download'],
'expiration_session' => $values['access_verification']['expiration_session'],
'retroactive' => $values['access_verification']['retroactive'],
'redirect' => $values['access_verification']['redirect'],
'text_download_access' => $values['protected_download_page']['text_download_access'],
'text_download_noaccess' => $values['protected_download_page']['text_download_noaccess'],
));
node_save($node);
drupal_set_message(t('Your changes have been saved.'));
// check if a testmail should be sent
$mail = $form_state['values']['access_verification']['testmail'];
if (!empty($mail)) {
$hash = webform_protected_downloads_create_hash();
webform_protected_downloads_send_mail(NULL, $node->nid, $mail, $hash);
drupal_set_message(t('A test mail has been send to @mail.', array(
'@mail' => $mail,
)));
}
}