/**
  * Get newsletters
  * @since Version 3.9.1
  * @return array
  */
 public function getNewsletters()
 {
     $return = array();
     foreach ($this->db->fetchAll("SELECT * FROM newsletter") as $row) {
         $Newsletter = new Newsletter($row['id']);
         $return[] = $Newsletter->getArray();
     }
     return $return;
 }
Exemple #2
0
 /**
  * Queue the newsletter for dispatch
  * @since Version 3.10.0
  * @return \Railpage\Newsletters\Weekly
  */
 private function queue()
 {
     $this->Notification->subject = "[News] " . $this->Newsletter->subject;
     $this->Notification->body = $this->html;
     $this->Notification->meta['decoration'] = $this->replacements;
     $this->Notification->addHeader("List-Unsubscribe", "<http://railpage.com.au/unsubscribe?email=##email_encoded##&newsletter=weekly>");
     Debug::LogCLI("Queueing notification for dispatch");
     $this->Notification->commit();
     $this->Newsletter->status = Newsletter::STATUS_SENT;
     Debug::LogCLI("Commiting the newsletter to the database");
     $this->Newsletter->commit();
     /**
      * Update the last sent timestamp
      */
     foreach ($this->user_ids as $user_id) {
         $query = "INSERT INTO nuke_users_flags (user_id, newsletter_weekly_last) VALUES(" . $user_id . ", NOW()) ON DUPLICATE KEY UPDATE newsletter_weekly_last = NOW()";
         $ZendDB->query($query);
     }
     return $this;
 }