Beispiel #1
0
 public function indexAction()
 {
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuReceiver'), array('action' => 'index'));
     $receiverMapper = new ReceiverMapper();
     $receivers = $receiverMapper->getReceivers();
     $this->getView()->set('receivers', $receivers);
     if ($this->getRequest()->getPost('saveContact')) {
         $receiver = $receiverMapper->getReceiverById($this->getRequest()->getPost('contact_receiver'));
         $name = $this->getRequest()->getPost('contact_name');
         $contactEmail = $this->getRequest()->getPost('contact_email');
         $subject = $this->getTranslator()->trans('contactWebsite') . $this->getConfig()->get('page_title') . ':<' . $name . '>(' . $contactEmail . ')';
         $captcha = trim(strtolower($this->getRequest()->getPost('captcha')));
         $message = $this->getRequest()->getPost('contact_message');
         if (empty($_SESSION['captcha']) || $captcha != $_SESSION['captcha']) {
             $this->addMessage('invalidCaptcha', 'danger');
         } elseif (empty($message)) {
             $this->addMessage('missingText', 'danger');
         } elseif (empty($name)) {
             $this->addMessage('missingName', 'danger');
         } elseif (empty($contactEmail)) {
             $this->addMessage('missingEmail', 'danger');
         } else {
             /*
              * @todo create a general sender.
              */
             $mail = new \Ilch\Mail();
             $mail->setTo($receiver->getEmail(), $receiver->getName())->setSubject($subject)->setFrom('*****@*****.**', 'automatische eMail')->setMessage($message)->addGeneralHeader('Content-type', 'text/plain; charset="utf-8"');
             $mail->send();
             $this->addMessage('sendSuccess');
         }
     }
 }
Beispiel #2
0
 public function showAction()
 {
     $jobsMapper = new JobsMapper();
     $userMapper = new UserMapper();
     $id = $this->getRequest()->getParam('id');
     $job = $jobsMapper->getJobsById($id);
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuJobs'), array('action' => 'index'))->add($job->getTitle(), array('action' => 'show', 'id' => $id));
     if ($this->getRequest()->getPost('saveApply')) {
         $title = trim($this->getRequest()->getPost('title'));
         $text = trim($this->getRequest()->getPost('text'));
         echo $title;
         if (empty($text)) {
             $this->addMessage('missingText', 'danger');
         } else {
             $date = new \Ilch\Date();
             $job = $jobsMapper->getJobsById($id);
             $user = $userMapper->getUserById($this->getUser()->getId());
             if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/jobs/layouts/mail/apply.php')) {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/jobs/layouts/mail/apply.php');
             } else {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/jobs/layouts/mail/apply.php');
             }
             $messageReplace = array('{applyAs}' => $this->getTranslator()->trans('applyAs') . ' ' . $title, '{content}' => $text, '{sitetitle}' => $this->getConfig()->get('page_title'), '{date}' => $date->format("l, d. F Y", true));
             $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
             $mail = new \Ilch\Mail();
             $mail->setTo($job->getEmail(), '')->setSubject($this->getTranslator()->trans('applyAs') . ' ' . $title)->setFrom($user->getEmail(), $user->getName())->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
             $mail->send();
             $this->addMessage('sendSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
     $this->getView()->set('job', $job);
     $this->getView()->set('jobs', $jobsMapper->getJobs(array('show' => 1)));
 }
Beispiel #3
0
 public function treatAction()
 {
     $newsletterMapper = new NewsletterMapper();
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuNewsletter'), array('action' => 'index'))->add($this->getTranslator()->trans('add'), array('action' => 'treat'));
     if ($this->getRequest()->isPost()) {
         $newsletterModel = new NewsletterModel();
         $subject = trim($this->getRequest()->getPost('subject'));
         $text = trim($this->getRequest()->getPost('text'));
         if (empty($subject)) {
             $this->addMessage('missingSubject', 'danger');
         } elseif (empty($text)) {
             $this->addMessage('missingText', 'danger');
         } else {
             $date = new \Ilch\Date();
             $newsletterModel->setDateCreated($date);
             $newsletterModel->setUserId($this->getUser()->getId());
             $newsletterModel->setSubject($this->getRequest()->getPost('subject'));
             $newsletterModel->setText($this->getRequest()->getPost('text'));
             $newsletterMapper->save($newsletterModel);
             if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/newsletter/layouts/mail/newsletter.php')) {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/newsletter/layouts/mail/newsletter.php');
             } else {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/newsletter/layouts/mail/newsletter.php');
             }
             $emails = $newsletterMapper->getMail();
             foreach ($emails as $email) {
                 $messageReplace = array('{subject}' => $this->getRequest()->getPost('subject'), '{content}' => $this->getRequest()->getPost('text'), '{sitetitle}' => $this->getConfig()->get('page_title'), '{date}' => $date->format("l, d. F Y", true), '{footer}' => $this->getTranslator()->trans('noReplyMailFooter'), '{unreadable}' => $this->getTranslator()->trans('mailUnreadable', $newsletterMapper->getLastId(), $email->getEmail()), '{unsubscribe}' => $this->getTranslator()->trans('mailUnsubscribe', $email->getEmail()));
                 $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
                 $mail = new \Ilch\Mail();
                 $mail->setTo($email->getEmail(), '')->setSubject($this->getRequest()->getPost('subject'))->setFrom($this->getConfig()->get('standardMail'), $this->getConfig()->get('page_title'))->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
                 $mail->send();
             }
             $this->addMessage('sendSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
     $emails = $newsletterMapper->getMail();
     $this->getView()->set('emails', $emails);
 }
Beispiel #4
0
 public function indexAction()
 {
     $profilMapper = new UserMapper();
     $profil = $profilMapper->getUserById($this->getRequest()->getParam('user'));
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuUserList'), array('controller' => 'index'))->add($profil->getName(), array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')))->add($this->getTranslator()->trans('menuMail'), array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
     if ($this->getRequest()->isPost()) {
         $sender = $profilMapper->getUserById($this->getUser()->getId());
         $name = $sender->getName();
         $email = $sender->getEmail();
         $subject = trim($this->getRequest()->getPost('subject'));
         $message = trim($this->getRequest()->getPost('message'));
         if (empty($subject)) {
             $this->addMessage('subjectEmpty');
             $this->redirect(array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         } elseif (empty($message)) {
             $this->addMessage('messageEmpty');
             $this->redirect(array('action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         } else {
             $sitetitle = $this->getConfig()->get('page_title');
             $date = new \Ilch\Date();
             if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/usermail.php')) {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/usermail.php');
             } else {
                 $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/user/layouts/mail/usermail.php');
             }
             $messageReplace = array('{content}' => $message, '{sitetitle}' => $sitetitle, '{date}' => $date->format("l, d. F Y", true));
             $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
             $mail = new \Ilch\Mail();
             $mail->setTo($profil->getEmail(), $profil->getName())->setSubject($subject)->setFrom($email, $name)->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
             $mail->send();
             $this->addMessage('emailSuccess');
             $this->redirect(array('controller' => 'profil', 'action' => 'index', 'user' => $this->getRequest()->getParam('user')));
         }
     }
     $this->getView()->set('profil', $profil);
 }
Beispiel #5
0
 public function inputAction()
 {
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuRegist'), array('action' => 'index'))->add($this->getTranslator()->trans('step2to3'), array('action' => 'input'));
     $registMapper = new UserMapper();
     $errors = array();
     if ($this->getRequest()->getPost('saveRegist')) {
         $name = $this->getRequest()->getPost('name');
         $password = $this->getRequest()->getPost('password');
         $password2 = $this->getRequest()->getPost('password2');
         $email = trim($this->getRequest()->getPost('email'));
         $captcha = trim(strtolower($this->getRequest()->getPost('captcha')));
         $profilName = $registMapper->getUserByName($name);
         $profilEmail = $registMapper->getUserByEmail($email);
         if (empty($_SESSION['captcha']) || $captcha != $_SESSION['captcha']) {
             $errors['captcha'] = 'invalidCaptcha';
         }
         if (!empty($profilName)) {
             $errors['name'] = 'nameExist';
         }
         if (!empty($profilEmail)) {
             $errors['email'] = 'emailExist';
         }
         if (empty($name)) {
             $errors['name'] = 'fieldEmpty';
         }
         if (empty($password)) {
             $errors['password'] = '******';
         }
         if (empty($password2)) {
             $errors['password2'] = 'fieldEmpty';
         }
         if ($password !== $password2) {
             $errors['password'] = '******';
             $errors['password2'] = 'fieldDiffersPassword';
         }
         if (empty($email)) {
             $errors['email'] = 'fieldEmpty';
         } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $errors['email'] = 'fieldEmail';
         }
         if (empty($errors)) {
             $groupMapper = new \Modules\User\Mappers\Group();
             $userGroup = $groupMapper->getGroupById(2);
             $currentDate = new \Ilch\Date();
             $model = new \Modules\User\Models\User();
             $model->setName($name);
             $model->setPassword((new PasswordService())->hash($password));
             $model->setEmail($email);
             $model->setDateCreated($currentDate);
             $model->addGroup($userGroup);
             if ($this->getConfig()->get('regist_confirm') == 0) {
                 $model->setDateConfirmed($currentDate);
             } else {
                 $confirmedCode = md5(uniqid(rand()));
                 $model->setConfirmed(0);
                 $model->setConfirmedCode($confirmedCode);
             }
             $registMapper->save($model);
             $_SESSION["name"] = $name;
             $_SESSION["email"] = $email;
             if ($this->getConfig()->get('regist_confirm') == 1) {
                 $sitetitle = $this->getConfig()->get('page_title');
                 $confirmCode = '<a href="' . BASE_URL . '/index.php/user/regist/confirm/code/' . $confirmedCode . '" class="btn btn-primary btn-sm">' . $this->getTranslator()->trans('confirmMailButtonText') . '</a>';
                 $date = new \Ilch\Date();
                 $layout = '';
                 if (isset($_SESSION['layout'])) {
                     $layout = $_SESSION['layout'];
                 }
                 if ($layout == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/registconfirm.php')) {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/registconfirm.php');
                 } else {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/user/layouts/mail/registconfirm.php');
                 }
                 $messageReplace = array('{content}' => $this->getConfig()->get('regist_confirm_mail'), '{sitetitle}' => $sitetitle, '{date}' => $date->format("l, d. F Y", true), '{name}' => $name, '{confirm}' => $confirmCode, '{footer}' => $this->getTranslator()->trans('noReplyMailFooter'));
                 $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
                 $mail = new \Ilch\Mail();
                 $mail->setTo($email, $name)->setSubject($this->getTranslator()->trans('automaticEmail'))->setFrom($this->getTranslator()->trans('automaticEmail'), $sitetitle)->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
                 $mail->send();
             }
             $this->redirect(array('action' => 'finish'));
         }
         $this->getView()->set('errors', $errors);
     }
     $this->getView();
 }
Beispiel #6
0
 public function forgotpasswordAction()
 {
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuLogin'), array('action' => 'index'))->add($this->getTranslator()->trans('menuForgotPassword'), array('action' => 'forgotpassword'));
     if ($this->getRequest()->getPost('saveNewPassword')) {
         $name = trim($this->getRequest()->getPost('name'));
         if (empty($name)) {
             $this->addMessage('missingNameEmail', 'danger');
         } else {
             $userMapper = new UserMapper();
             $user = $userMapper->getUserByEmail($name);
             if ($user == null) {
                 $user = $userMapper->getUserByName($name);
             }
             if (!empty($user)) {
                 $confirmedCode = md5(uniqid(rand()));
                 $user->setConfirmed(0);
                 $user->setConfirmedCode($confirmedCode);
                 $userMapper->save($user);
                 $name = $user->getName();
                 $email = $user->getEmail();
                 $sitetitle = $this->getConfig()->get('page_title');
                 $confirmCode = '<a href="' . BASE_URL . '/index.php/user/login/newpassword/code/' . $confirmedCode . '" class="btn btn-primary btn-sm">' . $this->getTranslator()->trans('confirmMailButtonText') . '</a>';
                 $date = new \Ilch\Date();
                 if ($_SESSION['layout'] == $this->getConfig()->get('default_layout') && file_exists(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/passwordchange.php')) {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/layouts/' . $this->getConfig()->get('default_layout') . '/views/modules/user/layouts/mail/passwordchange.php');
                 } else {
                     $messageTemplate = file_get_contents(APPLICATION_PATH . '/modules/user/layouts/mail/passwordchange.php');
                 }
                 $messageReplace = array('{content}' => $this->getConfig()->get('password_change_mail'), '{sitetitle}' => $sitetitle, '{date}' => $date->format("l, d. F Y", true), '{name}' => $name, '{confirm}' => $confirmCode, '{footer}' => $this->getTranslator()->trans('noReplyMailFooter'));
                 $message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
                 $mail = new \Ilch\Mail();
                 $mail->setTo($email, $name)->setSubject($this->getTranslator()->trans('automaticEmail'))->setFrom($this->getTranslator()->trans('automaticEmail'), $sitetitle)->setMessage($message)->addGeneralHeader('Content-type', 'text/html; charset="utf-8"');
                 $mail->send();
                 $this->addMessage('newPasswordEMailSuccess');
             } else {
                 $this->addMessage('newPasswordFailed', 'danger');
             }
         }
     }
 }