/**
  * @param SproutEmail_EntryModel    $entry
  * @param SproutEmail_CampaignModel $campaign
  *
  * @throws Exception
  * @throws \CDbException
  * @throws \Exception
  *
  * @return bool
  */
 public function saveEntry(SproutEmail_EntryModel $entry, SproutEmail_CampaignModel $campaign)
 {
     $isNewEntry = !$entry->id;
     if ($entry->id) {
         $entryRecord = SproutEmail_EntryRecord::model()->findById($entry->id);
         if (!$entryRecord) {
             throw new Exception(Craft::t('No entry exists with the ID “{id}”', array('id' => $entry->id)));
         }
     } else {
         $entryRecord = new SproutEmail_EntryRecord();
     }
     $entryRecord->campaignId = $entry->campaignId;
     $entryRecord->subjectLine = $entry->subjectLine;
     $entryRecord->setAttributes($entry->getAttributes());
     $entryRecord->setAttribute('recipients', $this->getOnTheFlyRecipients());
     $entryRecord->validate();
     $entry->addErrors($entryRecord->getErrors());
     if (!$entry->hasErrors()) {
         $transaction = craft()->db->getCurrentTransaction() === null ? craft()->db->beginTransaction() : null;
         try {
             if (craft()->elements->saveElement($entry)) {
                 // Now that we have an element ID, save it on the other stuff
                 if ($isNewEntry) {
                     $entryRecord->id = $entry->id;
                 }
                 $entryRecord->save(false);
                 $notificationEvent = craft()->request->getPost('notificationEvent');
                 sproutEmail()->mailers->saveRecipientLists($campaign, $entry);
                 if (!$notificationEvent || sproutEmail()->notifications->save($notificationEvent, $campaign->id)) {
                     if ($transaction && $transaction->active) {
                         $transaction->commit();
                     }
                     return true;
                 }
             }
         } catch (\Exception $e) {
             if ($transaction && $transaction->active) {
                 $transaction->rollback();
             }
             throw $e;
         }
     }
     return false;
 }