function workbench_email_notification_submit in Workbench Email 7.3
Same name and namespace in other branches
- 7 workbench_email.module \workbench_email_notification_submit()
Submit handler for the workbench_email form element.
Sends emails to the specific users selected in the form element.
Parameters
array $form: The form array.
array $form_state: The form state array
1 string reference to 'workbench_email_notification_submit'
File
- ./
workbench_email.form.inc, line 197 - Code for the Workbench Email Module.
Code
function workbench_email_notification_submit($form, &$form_state) {
if (isset($form_state['values']['workbench_email'])) {
$form['options']['#access'] ? $wrapper_id = 'options' : ($wrapper_id = 'revision_information');
foreach ($form_state['values']['workbench_email'] as $rid => $role_emails) {
foreach ($role_emails as $email) {
// If !$email means all users option selected.
if (!$email) {
$accounts = array();
$editors = array();
$author = workbench_email_get_all_transition_users($form_state['node'], 'node', $rid, $accounts, $editors);
$emails = workbench_email_filter_users($rid, $accounts, $editors, $author);
$email_transition = $form[$wrapper_id]['workbench_email'][$rid]['#hidden'];
foreach ($emails as $email => $name) {
workbench_email_mail_send($email, $email_transition, $form_state['node']);
}
}
else {
$email_transition = $form[$wrapper_id]['workbench_email'][$rid]['#hidden'];
workbench_email_mail_send($email, $email_transition, $form_state['node']);
}
}
}
}
}