public function getBody($subscriber, $items)
 {
     $items_body = $this->getItemsBody($items);
     $data = array_merge($subscriber, array('items' => $items_body));
     $template = new MailTemplate($this->template_name, $data);
     return $template->getBody();
 }
 /**
  * Send new password to defined E-Mail.
  */
 protected function send()
 {
     if ($crumbComponent = $this->document->componentManager->getBlockByName('breadCrumbs')) {
         $crumbComponent->addCrumb();
     }
     if ($component = $this->document->componentManager->getBlockByName('textBlockRestorePassword')) {
         $component->disable();
     }
     if (!isset($_POST['u_name'])) {
         $message = $this->translate('ERR_NO_U_NAME');
     } else {
         $uName = $_POST['u_name'];
         if (!($UID = $this->dbh->getScalar('user_users', 'u_id', array('u_name' => $uName)))) {
             $message = $this->translate('ERR_NO_U_NAME');
         } else {
             $password = User::generatePassword();
             $this->dbh->modify(QAL::UPDATE, 'user_users', array('u_password' => password_hash($password, PASSWORD_DEFAULT)), array('u_id' => $UID));
             $user = new User($UID);
             $template = new MailTemplate('user_restore_password', ['user_login' => $uName, 'user_name' => $user->getValue('u_fullname'), 'user_password' => $password, 'site_url' => E()->getSiteManager()->getCurrentSite()->base, 'site_name' => $this->translate('TXT_SITE_NAME')]);
             $mailer = new Mail();
             $mailer->setFrom($this->getConfigValue('mail.from'))->setSubject($template->getSubject())->setText($template->getBody())->setHtmlText($template->getHTMLBody())->addTo($uName);
             $message = $this->translate('MSG_PASSWORD_SENT');
             try {
                 $mailer->send();
             } catch (\Exception $e) {
                 $message = $e->getMessage();
             }
         }
     }
     $this->prepare();
     $messageField = new Field('restore_password_result');
     $messageField->setData($message);
     $this->getData()->addField($messageField);
 }
Beispiel #3
0
 /**
  * Send feedback.
  * It stores the access to database, sends message to the user and administrator.
  */
 protected function send()
 {
     if (!isset($_POST[$this->getTableName()])) {
         E()->getResponse()->redirectToCurrentSection();
     }
     try {
         $data[$this->getTableName()] = $_POST[$this->getTableName()];
         if (!$this->document->getUser()->isAuthenticated() && !$this->getParam('noCaptcha')) {
             $this->checkCaptcha();
         }
         if ($result = $this->saveData($data)) {
             $data = $data[$this->getTableName()];
             $senderEmail = '';
             if (isset($data['feed_email'])) {
                 $senderEmail = $data['feed_email'];
             } else {
                 $data['feed_email'] = $this->translate('TXT_NO_EMAIL_ENTERED');
             }
             $this->dbh->modify(QAL::UPDATE, $this->getTableName(), array('feed_date' => date('Y-m-d H:i:s')), array($this->getPK() => $result));
             if ($senderEmail) {
                 $template = new MailTemplate('feedback_form', $data);
                 $mailer = new Mail();
                 $mailer->setFrom($this->getConfigValue('mail.from'))->setSubject($template->getSubject())->setText($template->getBody())->setHtmlText($template->getHTMLBody())->addTo($senderEmail, $senderEmail)->send();
             }
             try {
                 $template = new MailTemplate('feedback_form_admin', $data);
                 $mailer = new Mail();
                 $recipientID = false;
                 if (isset($data['rcp_id']) && intval($data['rcp_id'])) {
                     $recipientID = $data['rcp_id'];
                 }
                 $mailer->setFrom($this->getConfigValue('mail.from'))->setSubject($template->getSubject())->setText($template->getBody())->setHtmlText($template->getHTMLBody())->addTo($this->getRecipientEmail($recipientID))->send();
             } catch (\Exception $e) {
             }
         }
         $this->prepare();
         if ($this->getParam('textBlock') && ($textBlock = $this->document->componentManager->getBlockByName($this->getParam('textBlock')))) {
             $textBlock->disable();
         }
         $this->response->redirectToCurrentSection('success/');
     } catch (Exception $e) {
         $this->failure($e->getMessage(), $data[$this->getTableName()]);
     }
 }
Beispiel #4
0
 /**
  * Save data.
  *
  * @throws SystemException
  */
 protected function saveData()
 {
     $password = $_POST[$this->getTableName()]['u_password'] = User::generatePassword();
     try {
         $result = $this->user->create($_POST[$this->getTableName()]);
         $template = new MailTemplate('user_registration', ['user_login' => $this->user->getValue('u_name'), 'user_name' => $this->user->getValue('u_fullname'), 'user_password' => $password, 'site_url' => E()->getSiteManager()->getCurrentSite()->base, 'site_name' => $this->translate('TXT_SITE_NAME')]);
         $mailer = new Mail();
         $mailer->setFrom($this->getConfigValue('mail.from'));
         $mailer->setSubject($template->getSubject());
         $mailer->setText($template->getBody());
         $mailer->setHtmlText($template->getHTMLBody());
         $mailer->addTo($this->user->getValue('u_name'));
         $mailer->send();
     } catch (\Exception $error) {
         throw new SystemException($error->getMessage(), SystemException::ERR_WARNING);
     }
 }