Commit 4cda3c67 authored by David Metzler's avatar David Metzler
Browse files

#2363295 Email array fix

parent 0f0b7a73
......@@ -63,19 +63,19 @@ class FrxEmailMergeDoc extends FrxDocument {
}
$count = count($docs);
if ($count) {
$form = drupal_get_form('forena_confirm_email', $emails, $count, $prompt_subject, $prompt_body);
$output = drupal_render($form);
$content = drupal_get_form('forena_confirm_email', $emails, $count, $prompt_subject, $prompt_body);
}
else {
drupal_set_message(t('No mail merge information in report. Displaying report instead.'), 'error');
$output = $body;
$content = array(
'content' => array('#markup' => $body),
);
}
$content = array(
'content' => array('#markup' => $output),
);
return $content;
}
public function output(&$output) {
return FALSE;
}
}
\ No newline at end of file
......@@ -169,10 +169,10 @@ function forena_my_reports_block() {
* @param integer $count Number of documents to send.
*/
function forena_confirm_email($formid, &$form_state, $docs, $count, $prompt_subject, $prompt_body) {
// Make sure user has permission for email merge.
if (!user_access('perform email merge')) {
drupal_access_denied();
exit();
// Make sure user has permission for email merge.
if (!user_access('perform email merge')) {
drupal_access_denied();
exit();
}
// Save arguments away for rebuild
if (!isset($form_state['storage']['args'])) {
......@@ -237,6 +237,7 @@ function forena_confirm_email_submit($form, &$form_state) {
$test_send = @$form_state['values']['send']=='test' ? TRUE : variable_get('forena_email_override', FALSE);
$max = (integer)$form_state['values']['max'];
$i = 0;
$sent = 0;
if (isset($form_state['values']['body']['value'])) {
$body = check_markup($form_state['values']['body']['value'],$form_state['values']['body']['format']);
}
......@@ -256,9 +257,18 @@ function forena_confirm_email_submit($form, &$form_state) {
// Remove bcc and cc
unset($doc['parms']['headers']);
}
if ($i <= $max) drupal_mail('forena', 'mailmerge', $to, language_default(), $doc['parms'], $from, TRUE);
if ($i <= $max) {
$sent++;
drupal_mail('forena', 'mailmerge', $to, language_default(), $doc['parms'], $from, TRUE);
}
}
drupal_set_message(t('Sent %count messages ', array('%count' => $sent)));
if ($form_state['values']['send'] == 'test') {
$form_state['rebuild'] = TRUE;
}
else {
$form_state['redirect'] = 'forena';
}
$form_state['rebuild'] = TRUE;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment