/**
  * send a new password 
  */
 function send()
 {
     $repError = $this->_check();
     if ($repError) {
         return $repError;
     }
     $rep = $this->getResponse("redirect");
     $rep->action = "password:index";
     $form = jForms::fill('password');
     if (!$form->check()) {
         return $rep;
     }
     $login = $form->getData('pass_login');
     $user = jAuth::getUser($login);
     if (!$user) {
         $form->setErrorOn('pass_login', jLocale::get('password.login.doesnt.exist'));
         return $rep;
     }
     if ($user->email != $form->getData('pass_email')) {
         $form->setErrorOn('pass_email', jLocale::get('password.email.unknown'));
         return $rep;
     }
     $pass = jAuth::getRandomPassword(8);
     $key = substr(md5($login . '-' . $pass), 1, 10);
     $user->status = JCOMMUNITY_STATUS_PWD_CHANGED;
     $user->request_date = date('Y-m-d H:i:s');
     $user->keyactivate = $key;
     jAuth::updateUser($user);
     $mail = new jMailer();
     $mail->From = jApp::config()->mailer['webmasterEmail'];
     $mail->FromName = jApp::config()->mailer['webmasterName'];
     $mail->Sender = jApp::config()->mailer['webmasterEmail'];
     $mail->Subject = jLocale::get('password.mail.pwd.change.subject');
     $tpl = new jTpl();
     $tpl->assign(compact('login', 'pass', 'key'));
     $tpl->assign('server', $_SERVER['SERVER_NAME']);
     $mail->Body = $tpl->fetch('mail_password_change', 'text');
     $mail->AddAddress($user->email);
     //$mail->SMTPDebug = true;
     $mail->Send();
     jForms::destroy('password');
     $rep->action = "password:confirmform";
     return $rep;
 }
 /**
  * save new user and send an email for a confirmation, with
  * a key to activate the account
  */
 function save()
 {
     if (jAuth::isConnected()) {
         return $this->noaccess();
     }
     $rep = $this->getResponse("redirect");
     $rep->action = "registration:index";
     $form = jForms::get('registration');
     if (!$form) {
         return $rep;
     }
     jEvent::notify('jcommunity_registration_init_form', array('form' => $form));
     $form->initFromRequest();
     if (!$form->check()) {
         return $rep;
     }
     $login = $form->getData('reg_login');
     if (jAuth::getUser($login)) {
         $form->setErrorOn('reg_login', jLocale::get('register.form.login.exists'));
         return $rep;
     }
     $pass = jAuth::getRandomPassword(8);
     $key = substr(md5($login . '-' . $pass), 1, 10);
     $user = jAuth::createUserObject($login, $pass);
     $user->email = $form->getData('reg_email');
     $user->nickname = $login;
     $user->status = JCOMMUNITY_STATUS_NEW;
     $user->request_date = date('Y-m-d H:i:s');
     $user->keyactivate = $key;
     $ev = jEvent::notify('jcommunity_registration_prepare_save', array('form' => $form, 'user' => $user));
     if (count($form->getErrors())) {
         return $rep;
     }
     $responses = $ev->getResponse();
     $hasErrors = false;
     foreach ($responses as $response) {
         if (isset($response['errorRegistration']) && $response['errorRegistration'] != "") {
             jMessage::add($response['errorRegistration'], 'error');
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return $rep;
     }
     jAuth::saveNewUser($user);
     jEvent::notify('jcommunity_registration_after_save', array('form' => $form, 'user' => $user));
     $gJConfig = jApp::config();
     $mail = new jMailer();
     $mail->From = $gJConfig->mailer['webmasterEmail'];
     $mail->FromName = $gJConfig->mailer['webmasterName'];
     $mail->Sender = $gJConfig->mailer['webmasterEmail'];
     $mail->Subject = jLocale::get('register.mail.new.subject');
     $tpl = new jTpl();
     $tpl->assign(compact('login', 'pass', 'key'));
     $tpl->assign('server', $_SERVER['SERVER_NAME']);
     $mail->Body = $tpl->fetch('mail_registration', 'text');
     $mail->AddAddress($user->email);
     $mail->Send();
     jForms::destroy('registration');
     $rep->action = "registration:confirmform";
     $rep->params = array('login' => $login);
     return $rep;
 }
Example #3
0
 /**
  * Send a message to a friend
  */
 public function send_a_message_to_friend()
 {
     $form = jForms::fill('hfnucontact~send_to_friend');
     $rep = $this->getResponse('redirect');
     if (!$form) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'jelix~error:403';
         return $rep;
     }
     if (!$form->check()) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'jelix~error:404';
         return $rep;
     }
     // the sender is  not connected and use contact form to send a message
     // to the contact defined in hfnucontact.ini.php
     if (!jAuth::isConnected()) {
         $gJConfig = jApp::config();
         $email = $gJConfig->mailer['webmasterEmail'];
         $login = $gJConfig->mailer['webmasterName'];
     } else {
         $email = jAuth::getUserSession()->email;
         $login = jAuth::getUserSession()->login;
     }
     $mail = new jMailer();
     $mail->From = $email;
     $mail->FromName = $login;
     $mail->Sender = $email;
     $mail->Subject = $form->getData('subject');
     $mail->ContentType = 'text/html';
     $tpl = new jTpl();
     $tpl->assign('login', $login);
     $tpl->assign('message', $form->getData('message'));
     $mail->Body = $tpl->fetch('hfnucontact~send_an_email', 'text');
     $mail->AddAddress($form->getData('email_to'));
     $mail->Send();
     jForms::destroy('hfnucontact~send_to_friend');
     $rep->action = 'hfnucontact~default:contacted';
     return $rep;
 }
Example #4
0
 /**
  * let's check if a member has subcribed to this forum, then mail him the new thread
  * @param int $id_forum id of the forum to unsubscribe
  * @param int $id_post id of the new post
  */
 public function checkSubscribedForumAndSendMail($id_forum, $thread_id)
 {
     $gJConfig = jApp::config();
     //check if this forum is already subscribe
     $recs = jDao::get('havefnubb~forum_sub')->getByIdForum($id_forum);
     foreach ($recs as $rec) {
         if (jAuth::getUserSession()->id != $rec->id_user) {
             $thread = jDao::get('havefnubb~threads_alone')->get($thread_id);
             $post = jDao::get('havefnubb~posts')->get($thread->id_last_msg);
             // let's mail the new post to the user
             $mail = new jMailer();
             $mail->From = $gJConfig->mailer['webmasterEmail'];
             $mail->FromName = $gJConfig->mailer['webmasterName'];
             $mail->Sender = $gJConfig->mailer['webmasterEmail'];
             $mail->Subject = jLocale::get('havefnubb~forum.new.post.in.forum');
             $tpl = new jTpl();
             $tpl->assign('post', $post);
             $tpl->assign('server', $_SERVER['SERVER_NAME']);
             $mail->Body = $tpl->fetch('havefnubb~forum_new_message', 'text');
             $mail->AddAddress(jDao::get('havefnubb~member')->getById($rec->id_user)->email);
             $mail->Send();
         }
     }
 }
 /**
  * Send an email to the administrator
  * 
  * @param objet $user jAuth user for the created user
  */
 private function sendEmailToAdmin($user)
 {
     $services = lizmap::getServices();
     if ($email = filter_var($services->adminContactEmail, FILTER_VALIDATE_EMAIL)) {
         $mail = new jMailer();
         $mail->Subject = jLocale::get("view~user.email.admin.subject");
         $mail->Body = jLocale::get("view~user.email.admin.body", array($user->login, $user->email));
         $mail->AddAddress($email, 'Lizmap Notifications');
         $mail->Send();
     }
 }
 /**
  * to answer to AuthNewUser event
  * @param object $event the given event to answer to
  */
 function onAuthNewUser($event)
 {
     $gJConfig = jApp::config();
     $toEmail = $gJConfig->havefnubb['admin_email'] != '' ? $gJConfig->havefnubb['admin_email'] : $gJConfig->mailer['webmasterEmail'];
     if ($toEmail == '') {
         throw new jException('havefnubb~main.email.config.not.done.properly');
     }
     $user = $event->getParam('user');
     // update the creation date
     $dao = jDao::get('havefnubb~member');
     $user = $dao->getByLogin($login = $user->login);
     if (!$user) {
         throw new jException('havefnubb~member.member.does.not.exist', array($login));
     }
     // put the current date
     $user->member_created = date('Y-m-d H:i:s');
     $user->nickname = $user->login;
     $dao->update($user);
     $mail = new jMailer();
     $mail->From = $gJConfig->mailer['webmasterEmail'];
     $mail->FromName = $gJConfig->mailer['webmasterName'];
     $mail->Sender = $gJConfig->mailer['webmasterEmail'];
     $mail->Subject = jLocale::get('havefnubb~member.registration.new.member.registered', array($user->login));
     $tpl = new jTpl();
     $tpl->assign('login', $user->login);
     $tpl->assign('server', $_SERVER['SERVER_NAME']);
     $mail->Body = $tpl->fetch('havefnubb~warn_new_registration', 'text');
     $mail->AddAddress($toEmail);
     $mail->Send();
 }
 function newsletter()
 {
     $rep = $this->getResponse('html');
     $token = uniqid('', true);
     $email = $this->param("email");
     $success = false;
     $msg = "Echec de l'operation : lien expiré ";
     $userFactory = jDao::get("user~user");
     $exst = $userFactory->getByLogin($email);
     $rep->bodyTpl = "changepassmessage";
     if (!empty($email) && jFilter::isEmail($email) && $exst->id) {
         $userFactory = jDao::get("user~user");
         $user = $userFactory->getByLogin($email);
         // $user->status=1;
         $user->keyactivate = $token;
         try {
             $userFactory->update($user);
             $success = true;
         } catch (Exception $e) {
             $success = false;
             $msg = "Opération échouée : " . "lien périmée";
         }
         if ($success) {
             $msg = "Opération effectuée avec succès : " . "votre mot de passe a ete réinitialisé" . " veuillez consulter votre mail pour l'activer";
             //mail
             $mail = new jMailer();
             $tpl = $mail->Tpl('user~changepassmail', true);
             $tpl->assign('user', $user);
             $mail->Send();
         }
     }
     $rep->body->assign('MESSAGE', $msg);
     return $rep;
 }
Example #8
0
 /**
  * Send an email to the members that have subsribe to this post
  * @param integer $id of the subscribed post
  * @return void
  */
 public static function sendMail($id)
 {
     if (!jAuth::isConnected()) {
         return;
     }
     $dao = jDao::get(self::$daoSub);
     $memberDao = jDao::get('havefnubb~member');
     //get all the members that subscribe to this thread except "ME" !!!
     $records = $dao->findSubscribedPost($id, jAuth::getUserSession()->id);
     $gJConfig = jApp::config();
     // then send them a mail
     foreach ($records as $record) {
         //get all the member that subscribe to the thread id $id (called by hfnupost -> savereply )
         $thread = jClasses::getService('havefnubb~hfnuposts')->getThread($id);
         $post = jClasses::getService('havefnubb~hfnuposts')->getPost($thread->id_last_msg);
         //get the email of the member that subscribes this thread
         $member = $memberDao->getById($record->id_user);
         $subject = jLocale::get('havefnubb~post.new.comment.received') . " : " . $post->subject;
         $mail = new jMailer();
         $mail->From = $gJConfig->mailer['webmasterEmail'];
         $mail->FromName = $gJConfig->mailer['webmasterName'];
         $mail->Sender = $gJConfig->mailer['webmasterEmail'];
         $mail->Subject = $subject;
         $tpl = new jTpl();
         $tpl->assign('server', $_SERVER['SERVER_NAME']);
         $tpl->assign('post', $post);
         $tpl->assign('login', $member->login);
         $mail->Body = $tpl->fetch('havefnubb~new_comment_received', 'text');
         $mail->AddAddress($member->email);
         $mail->Send();
     }
 }