You are here

protected function NewsletterNewsletterController::saveNew in Newsletter 7

Saves a new custom newsletter to database.

Parameters

$newsletter: A full newsletter object.

2 calls to NewsletterNewsletterController::saveNew()
NewsletterNewsletterController::create in includes/newsletter.newsletter.controller.inc
NewsletterNewsletterController::save in includes/newsletter.newsletter.controller.inc
Saves a newsletter to database.

File

includes/newsletter.newsletter.controller.inc, line 38
Controller class definition file for newsletter_newsletter entity.

Class

NewsletterNewsletterController
Newsletter Newsletter Controller

Code

protected function saveNew($newsletter) {
  $max_send_id = db_query('SELECT MAX(send_id) as send_id
      FROM {newsletter_newsletter}
      WHERE title = :title AND ntid = :ntid', array(
    ':title' => $newsletter->title,
    ':ntid' => $newsletter->ntid,
  ))
    ->fetchField();
  if ($max_send_id != '') {
    $newsletter->send_id = ++$max_send_id;
  }
  drupal_write_record('newsletter_newsletter', $newsletter);
  module_invoke_all('entity_insert', $newsletter, 'newsletter_newsletter');
}