Example #1
0
 /**
  * Zwraca z modelu dane uzytkownika o zadanym adresie e-mail
  *
  * @return Base_Db_Table_Row
  */
 protected function _getRecipient()
 {
     return $this->_model->getRecipientByMail($this->_getMail());
 }
Example #2
0
 /**
  * Load requested mail from database
  * @param string $name
  * @throws \LogicException
  */
 public function load($name)
 {
     if (!is_object($this->mailer)) {
         throw new \LogicException(__METHOD__ . ' called before the Mailer was set');
     }
     $mail_query = "SELECT name, subject, text_body, html_body FROM " . $this->prefix . "MAIL WHERE name = ?";
     $recipients_query = "SELECT name, email, field, status, error, date FROM " . $this->prefix . "MAIL_RECIPIENT WHERE mail = ?";
     // load mail main content
     $stm = $this->db->prepare($mail_query);
     if (false == $stm) {
         throw new \mysqli_sql_exception($this->db->errno . ': ' . $this->db->error . PHP_EOL . $this->db->error);
     }
     $stm->bind_param('s', $name);
     $stm->execute();
     $stm->bind_result($name, $subject, $textBody, $htmlBody);
     $stm->fetch();
     $mail = new Mail($this->mailer);
     $mail->setName($name);
     $mail->setSubject($subject);
     $mail->setTextBody($textBody);
     $mail->setHtmlBody($htmlBody);
     $stm->free_result();
     $stm->close();
     // load recipients
     $stm = $this->db->prepare($recipients_query);
     if (false == $stm) {
         throw new \mysqli_sql_exception($this->db->errno . ': ' . $this->db->error . PHP_EOL . $this->db->error);
     }
     $stm->bind_param('s', $name);
     $stm->execute();
     $stm->bind_result($name, $email, $field, $status, $error, $date);
     while ($stm->fetch()) {
         $method = 'add' . $field;
         $r = new MailRecipient($email, $name);
         if (!empty($error)) {
             $r->setError($error);
         }
         if (MailRecipient::$SENT == $status) {
             $r->setSent();
         }
         //$r->setDate($date);
         $mail->{$method}($r);
     }
     $stm->free_result();
     $stm->close();
     return $mail;
 }