function webform_email_insert in Webform 7.3
Same name and namespace in other branches
- 6.3 includes/webform.emails.inc \webform_email_insert()
- 7.4 includes/webform.emails.inc \webform_email_insert()
Insert a new e-mail setting into the database.
Parameters
$email: An array of settings for sending an e-mail.
3 calls to webform_email_insert()
- webform_email_edit_form_submit in includes/
webform.emails.inc - Submit handler for webform_email_edit_form().
- webform_node_insert in ./
webform.module - Implements hook_node_insert().
- webform_node_update in ./
webform.module - Implements hook_node_update().
File
- includes/
webform.emails.inc, line 547 - Provides interface and database handling for e-mail settings of a webform.
Code
function webform_email_insert($email) {
// TODO: This is not race-condition safe. Switch to using transactions?
if (!isset($email['eid'])) {
$next_id_query = db_select('webform_emails')
->condition('nid', $email['nid']);
$next_id_query
->addExpression('MAX(eid) + 1', 'eid');
$email['eid'] = $next_id_query
->execute()
->fetchField();
if ($email['eid'] == NULL) {
$email['eid'] = 1;
}
}
$email['excluded_components'] = implode(',', $email['excluded_components']);
$success = drupal_write_record('webform_emails', $email);
return $success ? $email['eid'] : FALSE;
}