function og_broadcast_form_submit in Organic groups 5.3
Same name and namespace in other branches
- 5.8 og.module \og_broadcast_form_submit()
- 6.2 og.pages.inc \og_broadcast_form_submit()
- 6 og.module \og_broadcast_form_submit()
File
- ./
og.module, line 328
Code
function og_broadcast_form_submit($form_id, $form_values) {
global $user;
$sql = og_list_users_sql(1);
$result = db_query($sql, $form_values['gid']);
$recipients = array();
while ($row = db_fetch_object($result)) {
$recipients[] = $row->uid;
}
$node = node_load($form_values[gid]);
$variables = array(
'@group' => $node->title,
'@body' => $form_values['body'],
'@site' => variable_get('site_name', drupal),
'!url_group' => url("node/{$node->nid}", NULL, NULL, TRUE),
'!url_unsubscribe' => url("og/unsubscribe/{$node->nid}", NULL, NULL, TRUE),
);
$message = array(
'from' => $user,
'subject' => $form_values['subject'],
'body' => _og_user_mail_text('og_admin_email_body', $variables),
);
// Send notifications to each member; Sending an array of recipients implies
// that this is a bulk message.
module_invoke_all('og', 'user broadcast', $gid, $recipients, $message);
drupal_set_message(format_plural(count($recipients), '1 message queued for delivery.', '@count messages queued for delivery.'));
drupal_goto("node/{$form_values[gid]}");
}