Esempio n. 1
0
 /**
  * eventSendWelcomeEmail
  * Send a welcome email to the newly registered user and also send
  * an alert to the administrator.
  * Emails are created from templates stored in the emailtemplate table.
  */
 function eventSendWelcomeEmail(EventControler $eventControler)
 {
     $emailFieldName = $this->getEmailField();
     $fields = $eventControler->fields;
     $emailto = $fields[$emailFieldName];
     $email_admin = $eventControler->email_admin;
     if (strlen($eventControler->emailtemplate_registration_admin) > 0) {
         $emailtemplate_registration_admin = $eventControler->emailtemplate_registration_admin;
     } elseif (!empty($emailtemplate['registration_admin'])) {
         $emailtemplate_registration_admin = $emailtemplate['registration_admin'];
     }
     if (strlen($eventControler->emailtemplate_registration) > 0) {
         $emailtemplate_registration = $eventControler->emailtemplate_registration;
     } else {
         $emailtemplate_registration = $emailtemplate['registration'];
     }
     if ($eventControler->doSave == "yes") {
         $email = new Emailer();
         $email->loadEmailer($this->getDbCon(), $emailtemplate_registration);
         $email->mergeArray($fields);
         if ($email->hasHtml) {
             $email->sendMailHtml($emailto);
         } else {
             $email->sendMailStandard($emailto);
         }
         // send an alert email to the administrator
         if (strlen($emailtemplate_registration_admin) > 0 && !empty($email_admin)) {
             $emailadmin = new Emailer();
             $emailadmin->loadEmailer($this->getDbCon(), $emailtemplate_registration_admin);
             $emailadmin->mergeArray($fields);
             if ($emailadmin->hasHtml()) {
                 $emailadmin->sendMailHtml($email_admin);
             } else {
                 $emailadmin->sendMailStandard($email_admin);
             }
         }
     }
 }
Esempio n. 2
0
 function eventSetCoWorker(EventControler $evtcl)
 {
     $goto = $evtcl->goto;
     if ($evtcl->fields['email_address'] != "") {
         $email_user = $evtcl->fields['email_address'];
     } else {
         $email_user = $evtcl->email;
     }
     if ($email_user != '' && !empty($email_user)) {
         // $email_user = $evtcl->email;//echo $email_user;exit;
         $iduser = $this->isUserExists($email_user);
         // user already in the db so just add
         if ($iduser) {
             $q = new sqlQuery($this->getDbCon());
             $q->query("select * from " . $this->table . " where iduser = "******" AND idcoworker= " . $iduser);
             //echo "select * from ".$this->table." where iduser = "******" AND idcoworker= ".$iduser;exit;
             if ($q->getNumRows() > 0) {
                 while ($q->fetch()) {
                     $accepted = $q->getData("accepted");
                 }
                 if ($accepted == 'Yes') {
                     $_SESSION['in_page_message'] = "cw_user-is-already-cw";
                 } elseif ($accepted == 'No') {
                     $_SESSION['in_page_message'] = "cw_already-have-pending-invitation";
                 }
             } else {
                 $this->iduser = $_SESSION['do_User']->iduser;
                 $this->idcoworker = $iduser;
                 $this->accepted = 'No';
                 $this->add();
                 $_SESSION['in_page_message'] = "cw_user-is-already-in-db-notification-sent";
             }
         } else {
             // Not found send the email.
             $enc_email = $this->encrypt($email_user);
             $q = new sqlQuery($this->getDbCon());
             $q->query("select * from " . $this->table . " where iduser = "******" AND enc_email = '" . $enc_email . "' AND accepted ='No'");
             //echo "select * from ".$this->table." where enc_email = '".$enc_email."' AND accepted ='No'";exit;
             if ($q->getNumRows() > 0) {
                 // If the invitation is still pending
                 $_SESSION['in_page_message'] = "cw_already-have-pending-invitation-to";
                 $_SESSION['in_page_message_data']['enc_email'] = $this->decrypt($enc_email);
             } else {
                 $this->iduser = $_SESSION['do_User']->iduser;
                 $this->idcoworker = 0;
                 $this->accepted = 'No';
                 $this->enc_email = $enc_email;
                 $this->add();
                 $last_id = $this->getInsertId($this->table, $this->primary_key);
                 include_once "class/Emailer.class.php";
                 $q = new sqlQuery($this->getDbCon());
                 $q->query("select * from " . $this->table . " where " . $this->primary_key . " = " . $last_id);
                 if ($q->getNumRows() > 0) {
                     while ($dData = $q->fetchArray()) {
                         $dData["firstname"] = $_SESSION['do_User']->firstname;
                         $dData["referer"] = $this->encrypt($last_id);
                         $full_name = $_SESSION['do_User']->firstname . " " . $_SESSION['do_User']->lastname;
                         $email = new Emailer();
                         $email->loadEmailer($this->getDbCon(), "invitation");
                         $email->setSender($full_name, $_SESSION['do_User']->email);
                         $email->mergeArray($dData);
                         if ($email->hasHtml()) {
                             $email->sendMailHtml($email_user);
                         } else {
                             $email->sendMailStandard($email_user);
                         }
                         $_SESSION['in_page_message'] = "cw_user-not-in-db-register";
                     }
                 }
             }
         }
     } else {
         $_SESSION['in_page_message'] = "cw_enter-emailid";
     }
 }
<?php

/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
/****
 * Event that send a thank you email to the registrar.
 * This is a sample to show how to use the email template package.
 *
 */
include_once "class/Emailer.class.php";
if ($doSave == "yes") {
    $email = new Emailer();
    $email->loadEmailer($this->getDbCon(), "regthank");
    $email->mBody = $email->stringFusion($email->mBody, $fields);
    $email->mBodyHtml = $email->stringFusion($email->mBodyHtml, $fields);
    $email->sendMailHtml($fields[Email]);
}
Esempio n. 4
0
 /**
  *************Overriding the method eventGetForgotPassword in Parent class to send decrypt password****************
  * Event registration.getForgotPassword
  * Returns the username and password for the
  * email id specified
  * @package registration
  * @author Philippe Lewicki, Abhik
  * @version 2.0
  */
 function eventGetForgotPassword(EventControler $eventControler)
 {
     $disp = new Display($eventControler->message_goto);
     $this->setLog("\n (" . $this->getObjectName() . ") Get Forgot Password " . date("Y/m/d H:i:s"));
     $conx = $this->getDbCon();
     $fields = $eventControler->fields;
     $useremail = $fields[$this->getEmailField()];
     include_once "class/Emailer.class.php";
     $qGetPass = new sqlQuery($this->getDbCon());
     $qGetPass->query("select * from `" . $this->getTable() . "` where `" . $this->getEmailField() . "`='" . $useremail . "'");
     $do_user_rel = new UserRelations();
     if ($qGetPass->getNumRows() > 0) {
         while ($dPass = $qGetPass->fetchArray()) {
             $email = new Emailer();
             $email->loadEmailer($this->getDbCon(), 'forgotpassword');
             $dPass["password"] = $do_user_rel->decrypt($dPass["password"]);
             $email->mergeArray($dPass);
             if ($email->hasHtml()) {
                 $email->sendMailHtml($dPass[$this->getEmailField()]);
             } else {
                 $email->sendMailStandard($dPass[$this->getEmailField()]);
             }
             $disp->addParam("message", _("Your password has been sent to: ") . $useremail);
         }
     } else {
         $disp->addParam("message", _("No user found with that email address"));
     }
     $eventControler->setDisplayNext($disp);
 }