function addEmail($email) { $newsletterEmail = new NewsletterEmailRecord(); $newsletterEmail->email = $email; $newsletterEmail->active = 0; $newsletterEmail->save(); return $newsletterEmail; }
function importNewsletterEmailAction() { $csvFile = new UploadedFile("csvFile"); try { $csvFile->validate(); $fileName = $csvFile->getTempName(); $buff = file_get_contents($fileName); $this->newsletterEmail->del(new Criteria()); foreach (preg_split("#[\r\n]+#", $buff) as $email) { $email = trim($email); if (empty($email)) { continue; } $newsletterEmail = new NewsletterEmailRecord(); $newsletterEmail->email = $email; $newsletterEmail->active = "1"; $newsletterEmail->save(); } } catch (Exception $e) { } $this->redirect($this->moduleLink("newsletterEmail")); }