function forena_confirm_email in Forena Reports 8
Same name and namespace in other branches
- 6.2 forena.common.inc \forena_confirm_email()
- 6 forena.common.inc \forena_confirm_email()
- 7.5 forena.common.inc \forena_confirm_email()
- 7 forena.common.inc \forena_confirm_email()
- 7.2 forena.common.inc \forena_confirm_email()
- 7.3 forena.common.inc \forena_confirm_email()
- 7.4 forena.common.inc \forena_confirm_email()
Email confirmation form. Confirms an email send based on mail merge
Parameters
array $form : Form definition start
array $form_state: Form state array
array $docs : An array of SimpleXML email documents to send
integer $count : Number of documents to send.
string $prompt_subject: Subject for the prompt
string $prompt_body: The body of the email entered.
File
- ./
forena.common.inc, line 160 - Common functions used throughout the project but loaded in this file to keep the module file lean.
Code
function forena_confirm_email($form, &$form_state, $docs, $count, $prompt_subject, $prompt_body) {
// Make sure user has permission for email merge.
if (!\Drupal::currentUser()
->hasPermission('perform email merge')) {
drupal_access_denied();
exit;
}
// Save arguments away for rebuild
if (!isset($form_state['storage']['args'])) {
$form_state['storage']['args'] = array(
'docs' => $docs,
'count' => $count,
'prompt_subject' => $prompt_subject,
'prompt_body' => $prompt_body,
);
}
else {
// Retrieve arguements for rebuild case
extract($form_state['storage']['args']);
}
if ($docs) {
$values = @$form_state['values'];
if ($prompt_subject) {
$form['subject'] = array(
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => @$values['subject'],
);
}
if ($prompt_body) {
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Message'),
'#default_value' => @$values['body'],
'#format' => \Drupal::config('forena.settings')
->get('forena_email_input_format'),
);
}
if (!\Drupal::config('forena.settings')
->get('forena_email_override')) {
$form['send'] = array(
'#type' => 'radios',
'#title' => t('Send Email'),
'#options' => array(
'send' => 'email to users',
'test' => 'emails to me (test mode)',
),
'#default_value' => 'test',
);
}
$form['max'] = array(
'#type' => 'textfield',
'#title' => 'Only send first',
'#description' => 'In test mode only, limits the number of messages to send',
'#default_value' => 1,
'#size' => 3,
);
$form_state['storage']['docs'] = $docs;
$form_state['storage']['count'] = $count;
}
return confirm_form($form, t('Send mail to users'), 'forena', t('Send email to %count users?', array(
'%count' => $count,
)));
}