protected function _beforeSave(Kwf_Model_Row_Interface $row)
 {
     parent::_beforeSave($row);
     $mail = new Kwf_Mail();
     $user = Kwf_Registry::get('userModel')->getAuthedUser();
     $mail->setReturnPath('noreply@' . preg_replace('#^www\\.#', '', Kwf_Config::getValue('server.domain')));
     $mail->setFrom($user->email, $user->__toString());
     foreach (Kwf_Registry::get('config')->developers as $dev) {
         if (isset($dev->sendClearCacheReport) && $dev->sendClearCacheReport) {
             $mail->addTo($dev->email);
         }
     }
     $mail->setSubject('Clear Cache Report. Affected: ' . $row->clear_cache_affected);
     $mail->setBodyText("Clear Cache Report\n\n" . "Web: " . Kwf_Registry::get('config')->application->name . " (" . Kwf_Registry::get('config')->application->id . ")\n" . "User: "******"\n" . "Time: " . date("d.m.Y, H:i:s") . "\n\n" . "Affected component / part:\n" . $row->clear_cache_affected . "\n\n" . "Steps to reproduce / description:\n" . $row->clear_cache_comment . "\n");
     $mail->send();
     $row->clear_cache_affected = '';
     $row->clear_cache_comment = '';
 }
 public function createMail(Kwc_Mail_Recipient_Interface $recipient, $data = null, $toAddress = null, $format = null, $addViewTracker = true)
 {
     $this->_mailData = $data;
     $mail = new Kwf_Mail();
     $name = $recipient->getMailFirstname() . ' ' . $recipient->getMailLastname();
     if (!$recipient->getMailFirstname() || !$recipient->getMailLastname()) {
         //no name at all if we don't have a complete name
         $name = null;
     }
     if ($toAddress) {
         $mail->addTo($toAddress, $name);
     } else {
         $mail->addTo($recipient->getMailEmail(), $name);
     }
     if (!$format && $recipient->getMailFormat() == Kwc_Mail_Recipient_Interface::MAIL_FORMAT_HTML || $format == Kwc_Mail_Recipient_Interface::MAIL_FORMAT_HTML) {
         $html = $this->getHtml($recipient, $addViewTracker);
         $mail->setDomain($this->getData()->getDomain());
         $mail->setAttachImages($this->_getSetting('attachImages'));
         $mail->setBodyHtml($html);
     }
     $mail->setBodyText($this->getText($recipient));
     $mail->setSubject($this->getSubject($recipient));
     if ($this->_getSetting('fromEmail')) {
         $mail->setFrom($this->_getSetting('fromEmail'), $this->_getSetting('fromName'));
     }
     if ($this->_getSetting('replyEmail')) {
         $mail->setReplyTo($this->_getSetting('replyEmail'));
     }
     if ($this->_getSetting('returnPath')) {
         $mail->setReturnPath($this->_getSetting('returnPath'));
     }
     $bccs = $this->_getSetting('bcc');
     if ($bccs) {
         if (!is_array($bccs)) {
             $bccs = array($bccs);
         }
         foreach ($bccs as $bcc) {
             $mail->addBcc($bcc);
         }
     }
     return $mail;
 }