Location: PHPKode > projects > Banshee PHP Framework > models/admin/newsletter.php
<?php
	class admin_newsletter_model extends model {
		public function newsletter_oke($info) {
			global $_output;

			$result = true;

			if ($info["title"] == "") {
				$_output->add_message("No title");
				$result = false;
			}

			if ($info["content"] == "") {
				$_output->add_message("No content");
				$result = false;
			}

			return $result;
		}

		public function send_newsletter($info) {
			$newsletter = new newsletter($info["title"], $this->settings->newsletter_email, $this->settings->newsletter_name);
			$newsletter->add_footer("To unsubscribe from this newsletter, click <a href=\"http://".$_SERVER["SERVER_NAME"]."/newsletter\">here</a>.");
			$newsletter->message($info["content"]);

			$query = "select * from subscriptions";
			if (($subscribers = $this->db->execute($query)) == false) {
				return false;
			}

			$chunks = array_chunk($subscribers, $this->settings->newsletter_bcc_size);

			foreach ($chunks as $subscribers) {
				foreach ($subscribers as $subscriber) {
					$newsletter->bcc($subscriber["email"]);
				}

				if ($newsletter->send($this->settings->newsletter_email, $this->settings->newsletter_name) == false) {
					return false;
				}
			}

			return true;
		}

		public function preview_newsletter($info) {
			$newsletter = new newsletter($info["title"], $this->settings->email, $this->settings->newsletter_name);
			$newsletter->message($info["content"]);

			return $newsletter->send($this->settings->webmaster_email);
		}
	}
?>
Return current item: Banshee PHP Framework