コード例 #1
0
ファイル: UserManager.php プロジェクト: tomas3093/cms-blog
 public function register($name, $password, $password2, $email)
 {
     if ($password != $password2) {
         throw new UserError('Heslo sa nezhoduje.');
     }
     //overenie spravneho tvaru hesla
     $validation = new Validation();
     $validation->checkPasswordLength($password);
     //aktualny cas
     $date = new DateTime();
     $time = $date->getTimestamp();
     //activation key
     $key = md5(uniqid(rand(), true));
     //data pre DB
     $user = array('name' => $name, 'password' => $this->returnHash($password), 'registration_date' => $time, 'last_visit' => $time, 'email' => $email, 'activation_key' => $key);
     //vlozenie dat do DB
     try {
         Database::insert('users', $user);
     } catch (PDOException $error) {
         throw new UserError('Zadané meno alebo email sa už používa');
     }
     //odoslanie aktivacneho emailu
     try {
         $emailSender = new EmailSender();
         $message = 'Dobrý deň,<br><br>';
         $message .= 'pre dokončenie Vašej registrácie na stránke www.tomasblazy.com kliknite na nasledujúci link:<br><br>';
         $message .= 'www.tomasblazy.com/registracia/' . $name . '/' . $key . '<br><br>';
         $message .= 'V prípade, že ste o žiadnu registráciu nežiadali, tento email ignorujte.<br><br>';
         $message .= 'Ďakujeme<br><br>Tím CodingBlog<br><a href="http://tomasblazy.com">tomasblazy.com</a>';
         $emailSender->send($email, 'Aktivácia účtu na Coding Blog', $message, 'CodingBlog', '*****@*****.**');
     } catch (PDOException $error) {
         throw new UserError($error->getMessage(), 'warning');
     }
 }
コード例 #2
0
 public function testSendFailure()
 {
     $this->orderSenderMock->expects($this->once())->method('send')->will($this->throwException(new \Magento\Framework\Mail\Exception('test message')));
     $this->messageManagerMock->expects($this->once())->method('addWarning');
     $this->loggerMock->expects($this->once())->method('critical');
     $this->assertFalse($this->emailSender->send($this->orderMock));
 }
コード例 #3
0
 /**
  * @param string $message
  * @return bool
  */
 public function consume($message)
 {
     $emailTo = $message['to'];
     $body = $message['body'];
     $emailFrom = $this->configProvider->getConfig()['defaultEmail'];
     $nameFrom = $this->configProvider->getConfig()['defaultName'];
     $this->sender->send($emailTo, 'someSubject', $body, $nameFrom, $emailFrom, $body);
 }
コード例 #4
0
 function process_message($msg)
 {
     $msg_body = json_decode($msg->body, true);
     if (isset($msg_body['params']) && is_array($msg_body['params'])) {
         $msg_body['params'] = json_encode($msg_body['params']);
     }
     $msg_body = array_values($msg_body);
     $dispatcher = new ShellDispatcher($msg_body, false);
     try {
         $dispatcher->dispatch();
     } catch (Exception $e) {
         RabbitMQ::publish(json_decode($msg->body, true), ['exchange' => 'requeueable', 'queue' => 'requeueable_messages']);
         $newMessage[] = $msg->body;
         $newMessage[] = '==>';
         $newMessage[] = $e->getMessage();
         $newMessage[] = $e->getFile();
         $newMessage[] = $e->getLine();
         $newMessage[] = $e->getTraceAsString();
         $newMessage[] = $e->getCode();
         $newMessage[] = $e->getPrevious();
         RabbitMQ::publish($newMessage, ['exchange' => 'unprocessed', 'queue' => 'unprocessed_messages']);
         EmailSender::sendEmail('*****@*****.**', $msg->body, $newMessage);
     }
     $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
     // Send a message with the string "quit" to cancel the consumer.
     if ($msg->body === 'quit') {
         $msg->delivery_info['channel']->basic_cancel($msg->delivery_info['consumer_tag']);
     }
 }
コード例 #5
0
ファイル: OrderBtns.php プロジェクト: larryu/magento-b2b
 /**
  * Sending the email out
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  */
 public function sendEmail($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) {
             throw new Exception('System Error: invalid order provided!');
         }
         if (!isset($param->CallbackParameter->emailAddress) || ($emailAddress = trim($param->CallbackParameter->emailAddress)) === '') {
             throw new Exception('System Error: invalid emaill address provided!');
         }
         $emailBody = '';
         if (isset($param->CallbackParameter->emailBody) && ($emailBody = trim($param->CallbackParameter->emailBody)) !== '') {
             $emailBody = str_replace("\n", "<br />", $emailBody);
         }
         $pdfFile = EntityToPDF::getPDF($order);
         $asset = Asset::registerAsset($order->getOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
         $type = $order->getType();
         EmailSender::addEmail('*****@*****.**', $emailAddress, 'BudgetPC ' . $type . ':' . $order->getOrderNo(), (trim($emailBody) === '' ? '' : $emailBody . "<br /><br />") . 'Please find attached ' . $type . ' (' . $order->getOrderNo() . '.pdf) from Budget PC Pty Ltd.', array($asset));
         $order->addComment('An email sent to "' . $emailAddress . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         $results['item'] = $order->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
コード例 #6
0
 /**
  * @param $json
  * @param $email_type
  * @return ErrorResponse|null|Response
  */
 public static function setNewPassword($json, $email_type)
 {
     $response = null;
     $missing_fields = UserController::validateJSONFormat($json, User::REQUIRED_PASSWORD_RESET_FIELD);
     // Check that required fields are not missing
     if (!$missing_fields) {
         $user_mapper = new UserDBMapper();
         $email = $json['email'];
         $user = User::fromDBArray($user_mapper->getByEmail($email));
         // Set random password
         $password = ResetPasswordController::getRandomString(ResetPasswordController::PASSWORD_LENGTH);
         $json['password'] = $password;
         $id = $user->getId();
         $reset_password_user = User::fromResetPasswordQuery($id, $json);
         if ($reset_password_user) {
             $db_response = $user_mapper->resetPassword($reset_password_user);
             if ($db_response instanceof DBError) {
                 $response = new ErrorResponse($db_response);
             } else {
                 $reset_password_user = $user_mapper->getById($id);
                 if ($reset_password_user) {
                     EmailSender::sendEmail($email, $password, $email_type);
                     // Sending Email notification
                     $response = new Response(json_encode(array('message' => ResetPasswordController::RESET_PASSWORD_ACCEPTED_MESSAGE), JSON_PRETTY_PRINT), Response::STATUS_CODE_ACCEPTED);
                 } else {
                     $response = new ErrorResponse(new NotFoundError());
                 }
             }
         }
         return $response;
     }
     return new Response($response);
 }
コード例 #7
0
 public function process($parameters)
 {
     $emailSender = new EmailSender();
     $validation = new Validation();
     $this->head = array('title' => 'Kontaktný formulár', 'key_words' => 'kontakt, email, formulár', 'description' => 'Kontaktný formulár blogu.');
     if ($_POST) {
         //odstranenie skodliveho kodu z formularovych poli
         $captchaAnswer = strip_tags($_POST['captchaAnswer']);
         $message = htmlspecialchars($_POST['message']);
         try {
             //ak bol spravne vyplneny antispam
             if ($validation->checkCaptcha($_POST['captchaNumber1'], $_POST['captchaNumber2'], $captchaAnswer)) {
                 $emailSender->send('*****@*****.**', 'Správa z webu', $message, $_POST['email']);
                 $this->createMessage('Správa bola úspešne odoslaná', 'success');
                 $this->redirect('');
             } else {
                 throw new UserError('Chybne vyplnený antispam.');
             }
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //ak bol odoslany formular, zachovanie vyplnenej spravy a emailu
     $this->data['message'] = '';
     if (isset($_POST['message'])) {
         $this->data['message'] = $_POST['message'];
     }
     $this->data['email'] = '@';
     if (isset($_POST['email'])) {
         $this->data['email'] = $_POST['email'];
     }
     //vytvorenie antispam otazky
     $this->data['captcha'] = $validation->returnCaptcha();
     //nastavenie sablony
     $this->view = 'contactForm';
 }
コード例 #8
0
 /**
  * Opens DB connection if it is currently not
  * @throws CException if connection fails
  */
 protected function open()
 {
     try {
         parent::open();
     } catch (Exception $exception) {
         // email notif ke Developer/Sysadmin buat restart service
         $email = new EmailSender();
         $email->setSubject('Critical Error - Database not active');
         $email->setBody($exception->getMessage() . '<br />' . CHtml::link('Restart Database Service', 'https://bmustudio.com:8083/restart/service/?srv=mysql'));
         $email->setTo([Yii::app()->params['emails']['sysadmin'] => Yii::app()->params['emails']['sysadmin']]);
         $email->setCC(Yii::app()->params['emails']['developerList']);
         $email->send();
         throw new CHttpException(500, "Maaf database sedang kami matikan sementara, coba akses beberapa saat lagi.");
     }
 }
コード例 #9
0
ファイル: MessageSender.php プロジェクト: larryu/magento-b2b
 public static function run()
 {
     $start = self::_logMsg("== START: processing Messages ==", __CLASS__, __FUNCTION__);
     $messages = self::_getAndMarkMessages();
     self::_logMsg("GOT " . count($messages) . ' Message(s): ', __CLASS__, __FUNCTION__);
     foreach ($messages as $message) {
         self::_logMsg("    Looping message(ID=" . $message->getId() . ': ', __CLASS__, __FUNCTION__);
         try {
             Dao::beginTransaction();
             EmailSender::sendEmail($message->getFrom(), $message->getTo(), $message->getSubject(), $message->getBody(), $message->getAttachmentAssetIdArray());
             $message->setStatus(Message::STATUS_SENT)->save();
             Dao::commitTransaction();
             self::_logMsg("    SUCCESS sending message(ID=" . $message->getId() . ').', __CLASS__, __FUNCTION__);
         } catch (Exception $ex) {
             Dao::rollbackTransaction();
             $message->setStatus(Message::STATUS_FAILED)->save();
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getMessage(), __CLASS__, __FUNCTION__);
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getTraceAsString(), __CLASS__, __FUNCTION__);
         }
     }
     $end = new UDate();
     self::_logMsg("== FINISHED: " . count($messages) . " Message(s) == ", __CLASS__, __FUNCTION__);
 }
コード例 #10
0
 function __construct($query, $boundary, $logpass, $shellManager, $type = "htmle", $auto = true)
 {
     global $translation;
     $this->query = $query;
     $this->files = isset($_POST['files']) ? $_POST['files'] : null;
     $this->outserver = isset($_POST['outserver']) ? $_POST['outserver'] : null;
     $this->saveInTxtLog = isset($_POST['saveLogInTxt']) && $_POST['saveLogInTxt'] == "true" ? true : false;
     if (SERVICEMODE) {
         $this->outserver = null;
     }
     $this->output = "";
     $this->shellManager = $shellManager;
     if (!$auto) {
         return;
     }
     if ($this->query == "preview") {
         if (SERVICEMODE) {
             if ($type == "text") {
                 $_POST['text'] = $translation->getWord("service-warning-text") . PHP_EOL . $_POST['text'];
             } else {
                 $_POST['text'] = "<div style='color:red;font-weight:bold;'>" . $translation->getWord("service-warning-text") . "</div>" . $_POST['text'];
             }
         }
         $email = EmailSender::makeEmail($_POST['to'], $_POST['fromname'], $_POST['frommail'], $_POST['replymail'], $_POST['tema'], $_POST['additional'], $_POST['text'], $_POST['enumer'], $this->query == "preview");
         $this->output = $email->text;
         return;
     }
     if ($this->query == "send") {
         $emailSender = new EmailSender();
         if (SERVICEMODE) {
             if ($type == "text") {
                 $_POST['text'] = $translation->getWord("service-warning-text") . PHP_EOL . $_POST['text'];
             } else {
                 $_POST['text'] = "<div style='color:red;font-weight:bold;'>" . $translation->getWord("service-warning-text") . "</div>" . $_POST['text'];
             }
         }
         $emailSender->Send($type, $this->files, $this->outserver, $boundary, array('to' => $_POST['to'], 'fromname' => $_POST['fromname'], 'frommail' => $_POST['frommail'], 'replymail' => $_POST['replymail'], 'tema' => $_POST['tema'], 'additional' => $_POST['additional'], 'text' => $_POST['text'], 'sendInBase64' => $_POST['sendInBase64'] == "true", 'enumer' => $_POST['enumer']));
         $this->output = $emailSender->getOutput();
         if ($this->saveInTxtLog) {
             $this->saveToTxtLog($this->output);
         }
         return;
     }
     if ($this->query == "sendFromTemplate") {
         if (SERVICEMODE) {
             return;
         }
         $emailSender = new EmailSender();
         $emailSender->SendFromTemplate($_POST['template'], $_POST['to'], $this->outserver, $boundary);
         $this->output = $emailSender->getOutput();
         if ($this->saveInTxtLog) {
             $this->saveToTxtLog($this->output);
         }
         return;
     }
     if ($this->query == "upload_universal") {
         $this->output = TransferIface::uploadFile(isset($_FILES['elist']) ? $_FILES['elist'] : null);
         return;
     }
     if ($this->query == "savedata") {
         $this->output = TransferIface::downloadFile(isset($_POST['savedata']) ? $_POST['savedata'] : null, $_POST['filename']);
         return;
     }
     if ($this->query == "changepass") {
         if (SERVICEMODE) {
             return;
         }
         $this->output = $this->changePass($_POST['login'], $_POST['pass'], $logpass);
         return;
     }
     if ($this->query == "pingoutserver") {
         if (SERVICEMODE) {
             return;
         }
         $this->output = Shell::check($_POST['server']);
         return;
     }
     if ($this->query == "linesinfile") {
         if (SERVICEMODE) {
             return;
         }
         $this->output = AMUtil::linesInFile($_POST['file_path']);
         return;
     }
     if ($this->query == "saveSettings") {
         if (SERVICEMODE) {
             return;
         }
         $result = Settings::Save($_POST['settings']);
         if ($result) {
             $this->output = $translation->getWord("settings-saved");
         } else {
             $this->output = $translation->getWord("settings-save-error");
         }
         return;
     }
     if ($this->query == "removeSettings") {
         if (SERVICEMODE) {
             return;
         }
         Settings::Remove();
         $this->output = $translation->getWord("settings-removed");
         return;
     }
     if ($this->query == "loadSettings") {
         $data = Settings::Load();
         if (!$data) {
             $this->output = "";
         } else {
             $this->output = $data;
         }
         return;
     }
     if ($this->query == "sendInBackground") {
         if (SERVICEMODE) {
             return;
         }
         $emailSender = new EmailSender();
         $outservers = isset($_POST['outservers']) ? explode("\n", $_POST['outservers']) : array();
         $additional = array();
         foreach ($_POST['additional'] as $n => $values) {
             $additional[$n] = explode("\n", $values);
         }
         $emailSender->sendInBackground($_POST['type'], $_POST['files'], $boundary, $outservers, $_POST['timeout'], array('to' => explode("\n", $_POST['to']), 'fromname' => explode("\n", $_POST['fromname']), 'frommail' => explode("\n", $_POST['frommail']), 'replymail' => explode("\n", $_POST['replymail']), 'subject' => explode("\n", $_POST['subject']), 'additional' => $additional, 'text' => $_POST['text'], 'sendInBase64' => $_POST['sendInBase64'], 'randomTimeout' => $_POST['randomTimeout'], 'enumer' => null));
         //NO RETURN ^_^
     }
     if ($this->query == "getBackgroundState") {
         if (SERVICEMODE) {
             return;
         }
         $this->output = json_encode(EmailSender::loadState());
         return;
     }
     if ($this->query == "setBackgroundState") {
         if (SERVICEMODE) {
             return;
         }
         $this->output = EmailSender::setState($_POST['isRunning'] == "true");
         return;
     }
     if ($this->query == "selfDiagnostics") {
         //if(SERVICEMODE) return;
         $this->output = $this->selfDiagnostics();
         return;
     }
 }
コード例 #11
0
 /**
  * Send token for verify email
  * @param User $user
  */
 public function emailVerify($user)
 {
     $email = new EmailSender();
     $email->view = 'verify';
     $email->setSubject('Verifikasi Email');
     $email->setBody(['user' => $user, 'token' => $this->token($user)]);
     $email->setTo([$user->email => $user->username]);
     return $email->send();
 }
コード例 #12
0
 public static function setState($isRunning, $statefile = ".state.am.php")
 {
     $data = EmailSender::loadState();
     $data['isRunning'] = $isRunning;
     return EmailSender::saveState($data['isRunning'], $data['position'], $data['count']);
 }
コード例 #13
0
<?php

include_once "includes/SystemConfiguration.class.php";
include "includes/language.php";
global $systemConfiguration;
global $logger;
session_start();
$systemConfiguration->assertReferer();
if (!isset($_REQUEST['form']) || sizeof($_REQUEST['form']) == 0) {
    $_SESSION['errors'] = array();
    $_SESSION['errors'][] = BOOKING_FAILURE_INVALID_REQUEST;
    header("Location: error.php");
}
$emailSender = new EmailSender();
if ($emailSender->sendContactEmail($_REQUEST['form'])) {
    header("Location: contact-success.php");
} else {
    $_SESSION['errors'] = array();
    $_SESSION['errors'][] = CONTACT_SEND_ERROR . " " . $systemConfiguration->getHotelDetails()->getHotelEmail();
    header("Location: error.php");
}
コード例 #14
0
ファイル: paypal.php プロジェクト: earthtravels/maxtena
<?php

// Setup class
include_once "includes/SystemConfiguration.class.php";
include "includes/language.php";
global $systemConfiguration;
global $logger;
$logger->LogInfo(__FILE__);
$systemConfiguration->assertReferer();
$logger->LogInfo("Loading payment gateway for code 'pp' ...");
$paypalPaymentGateway = PaymentGateway::fetchFromDbForCode("pp");
if ($paypalPaymentGateway == null) {
    $logger->LogError("Payment gateway could not be found!");
    header('Location: booking-failure.php?error_code=9');
}
$emailSender = new EmailSender();
require_once 'paypal.class.php';
$p = new paypal_class();
$p->paypal_url = $paypalPaymentGateway->getUrl();
// 'https://www.sandbox.paypal.com/cgi-bin/webscr';   // testing paypal url
// 'https://www.paypal.com/cgi-bin/webscr';     // paypal url
// setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php')
$this_script = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
// if there is not action variable, set the default action of 'process'
if (empty($_GET['action'])) {
    $_GET['action'] = 'process';
}
switch ($_GET['action']) {
    case 'process':
        // Process and order...
        $logger->LogInfo("Procesisng request  for payment to PayPal ...");
コード例 #15
0
ファイル: POController.php プロジェクト: larryu/magento-b2b
 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     $daoStart = false;
     try {
         Dao::beginTransaction();
         $daoStart = true;
         $supplier = Supplier::get(trim($param->CallbackParameter->supplier->id));
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid Supplier passed in!');
         }
         $supplierContactName = trim($param->CallbackParameter->supplier->contactName);
         $supplierContactNo = trim($param->CallbackParameter->supplier->contactNo);
         $supplierEmail = trim($param->CallbackParameter->supplier->email);
         if (!empty($supplierContactName) && $supplierContactName !== $supplier->getContactName()) {
             $supplier->setContactName($supplierContactName);
         }
         if (!empty($supplierContactNo) && $supplierContactNo !== $supplier->getContactNo()) {
             $supplier->setContactNo($supplierContactNo);
         }
         if (!empty($supplierEmail) && $supplierEmail !== $supplier->getEmail()) {
             $supplier->setEmail($supplierEmail);
         }
         $supplier->save();
         $purchaseOrder = PurchaseOrder::create($supplier, trim($param->CallbackParameter->supplierRefNum), $supplierContactName, $supplierContactNo, StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->shippingCost)), StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->handlingCost)))->setTotalAmount(StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalPaymentDue)))->setEta(trim($param->CallbackParameter->eta))->setStatus(PurchaseOrder::STATUS_NEW)->save()->addComment(trim($param->CallbackParameter->comments), Comments::TYPE_PURCHASING);
         foreach ($param->CallbackParameter->items as $item) {
             if (!($product = Product::get(trim($item->productId))) instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             $purchaseOrder->addItem($product, StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice)), intval(trim($item->qtyOrdered)));
         }
         if ($param->CallbackParameter->submitToSupplier === true) {
             $purchaseOrder->setStatus(PurchaseOrder::STATUS_ORDERED)->save();
         }
         $daoStart = false;
         Dao::commitTransaction();
         $results['item'] = $purchaseOrder->getJson();
         if (isset($param->CallbackParameter->confirmEmail) && trim($confirmEmail = trim($param->CallbackParameter->confirmEmail)) !== '') {
             $pdfFile = EntityToPDF::getPDF($purchaseOrder);
             $asset = Asset::registerAsset($purchaseOrder->getPurchaseOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
             EmailSender::addEmail('*****@*****.**', $confirmEmail, 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             EmailSender::addEmail('*****@*****.**', '*****@*****.**', 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             $purchaseOrder->addComment('An email sent to "' . $confirmEmail . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         }
     } catch (Exception $ex) {
         if ($daoStart === true) {
             Dao::rollbackTransaction();
         }
         $errors[] = $ex->getMessage() . "<pre>" . $ex->getTraceAsString() . "</pre>";
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
コード例 #16
0
ファイル: User.php プロジェクト: ngardner/BentoCMS
 function actionChangePassword($params = '')
 {
     $this->objAuthentication->requiresAccount();
     $errorMsg = false;
     $changedpassword = false;
     if (!empty($params['changepassword'])) {
         $objUser = new UserModel();
         if (!empty($params['orignal_pw']) && !empty($params['password']) && !empty($params['password2'])) {
             // verify old password
             $passwordMatch = $objUser->testPassword($this->objAuthentication->user_id, $params['orignal_pw']);
             if ($passwordMatch) {
                 $objValidation = new Validator();
                 $objValidation->validatePassword($params['password']);
                 $objValidation->passwordsMatch($params['password'], $params['password2']);
                 if ($objValidation->hasError) {
                     $errorMsg = $objValidation->getError();
                     if (is_array($errorMsg)) {
                         $errorMsg = implode(', ', $errorMsg);
                     }
                 } else {
                     $saveData = array();
                     $saveData['id'] = $this->objAuthentication->user_id;
                     $saveData['password'] = $this->objAuthentication->encryptPassword($params['password']);
                     $changedpassword = $objUser->save($saveData, 'users');
                     if ($changedpassword) {
                         $objEmailer = new EmailSender();
                         $objEmailer->sendUserChangePassword($this->objAuthentication->user_id);
                     } else {
                         $errorMsg = 'Unable to change password.';
                     }
                 }
             } else {
                 $errorMsg = 'Current password incorrect.';
             }
         } else {
             $errorMsg = 'Current password and new password are required.';
         }
     }
     $objLayout = new LayoutModel();
     $objTemplate = new TemplatesModel();
     $layoutInfo = $objLayout->loadLayout();
     $template = $objTemplate->loadTemplateFromKeyname('user-changepassword');
     $this->view->assign('errorMsg', $errorMsg);
     $this->view->assign('changedpassword', $changedpassword);
     $this->view->assign('content', $this->view->fetch('fromstring:' . $template['content']));
     $this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar']));
     $this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar']));
     $this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code']));
     $this->finish();
 }
コード例 #17
0
 /**
  * saveOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function saveOrder($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!($purchaseOrder = PurchaseOrder::get(trim($param->CallbackParameter->id))) instanceof PurchaseOrder) {
             throw new Exception('Invalid Purchase Order passed in!');
         }
         if (!($supplier = Supplier::get(trim($param->CallbackParameter->supplierId))) instanceof Supplier) {
             throw new Exception('Invalid Supplier passed in!');
         }
         $isSubmit = isset($param->CallbackParameter->isSubmit) && intval($param->CallbackParameter->isSubmit) === 1 ? true : false;
         $supplierRefNum = trim($param->CallbackParameter->supplierRefNum);
         $supplierContactName = trim($param->CallbackParameter->contactName);
         $supplierContactNo = trim($param->CallbackParameter->contactNo);
         $shippingCost = trim($param->CallbackParameter->shippingCost);
         $handlingCost = trim($param->CallbackParameter->handlingCost);
         $comment = trim($param->CallbackParameter->comments);
         $status = trim($param->CallbackParameter->status);
         $purchaseOrderTotalAmount = trim($param->CallbackParameter->totalAmount);
         $purchaseOrderTotalPaid = trim($param->CallbackParameter->totalPaid);
         $purchaseOrder->setTotalAmount($purchaseOrderTotalAmount)->setTotalPaid($purchaseOrderTotalPaid)->setSupplierRefNo($supplierRefNum)->setSupplierContact($supplierContactName)->setSupplierContactNumber($supplierContactNo)->setshippingCost($shippingCost)->sethandlingCost($handlingCost)->setStatus($status)->save();
         $purchaseOrder->addComment($comment, Comments::TYPE_PURCHASING);
         foreach ($param->CallbackParameter->items as $item) {
             $productUnitPrice = trim($item->unitPrice);
             $qtyOrdered = trim($item->qtyOrdered);
             $productTotalPrice = trim($item->totalPrice);
             if (!($product = Product::get(trim($item->productId))) instanceof Product) {
                 throw new Exception('Invalid Product passed in!');
             }
             if (!isset($item->id) || trim($item->id) === '') {
                 $poItem = null;
                 $purchaseOrder->addItem($product, $productUnitPrice, $qtyOrdered, '', '', $productTotalPrice, $poItem);
             } else {
                 if (($poItem = PurchaseOrderItem::get($item->id)) instanceof PurchaseOrderItem) {
                     $poItem->setProduct($product)->setUnitPrice($productUnitPrice)->setTotalPrice($productTotalPrice)->setQty($qtyOrdered);
                 }
             }
             $poItem->setActive(intval($item->active) === 1)->save();
         }
         $results['item'] = $purchaseOrder->getJson();
         if ($isSubmit === true) {
             $pdfFile = EntityToPDF::getPDF($purchaseOrder);
             $confirmEmail = trim($param->CallbackParameter->contactEmail);
             $asset = Asset::registerAsset($purchaseOrder->getPurchaseOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
             EmailSender::addEmail('*****@*****.**', $confirmEmail, 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             EmailSender::addEmail('*****@*****.**', '*****@*****.**', 'BudgetPC Purchase Order:' . $purchaseOrder->getPurchaseOrderNo(), 'Please Find the attached PurchaseOrder(' . $purchaseOrder->getPurchaseOrderNo() . ') from BudgetPC.', array($asset));
             $purchaseOrder->addComment('An email sent to "' . $confirmEmail . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         }
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
コード例 #18
0
ファイル: EmailController.php プロジェクト: reggi49/plansys
 public function actionSendemail()
 {
     EmailSender::send(['subject' => "Testing email builder", 'to' => "*****@*****.**", 'template' => 'email2', 'params' => ['ini' => ['variable' => 'agak', 'dalem' => ['sekali' => [1, 23, 4]]], 'text' => ['header', 'content', 'footer'], 'img' => ['manjadda.jpg', 'manjadda.jpg']]]);
 }
コード例 #19
0
function processPayOnArrival()
{
    global $bookingDetails;
    global $systemConfiguration;
    global $logger;
    global $language_selected;
    $logger->LogInfo("Processing payment on arrival ...");
    $transactionId = "N/A";
    $booking = $bookingDetails->booking;
    $paymentGateway = $bookingDetails->paymentGateway;
    $logger->LogInfo("Creating bottom portion of invoice ...");
    $logger->LogInfo("Compposing invoice ...");
    $invoiceHtml = '<br />' . "\n";
    $invoiceHtml .= '<table  style="font-family:Verdana, Geneva, sans-serif; font-size: 12px; background:#999999; width:700px; border:none;" cellpadding="4" cellspacing="1">' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" colspan="2" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_BILLING . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" width="30%" style="font-weight:bold; font-variant:small-caps;background:#ffffff;" width="33%">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_PAYMENT_OPTION . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '		<td align="left" style="background:#ffffff;">' . "\n";
    $invoiceHtml .= '			' . $paymentGateway->gatewayName->getText($language_selected) . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" width="30%" style="font-weight:bold; font-variant:small-caps; background:#ffffff;" width="33%">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_TRANSACTION . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '		<td align="left" style="background:#ffffff;">' . "\n";
    $invoiceHtml .= '			' . $transactionId . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '</table>' . "\n";
    $booking->invoice .= $invoiceHtml;
    $booking->paymentTransactionId = $transactionId;
    $booking->paypalEmail = "";
    $booking->isPaymentSuccessful = true;
    $logger->LogInfo("Saving booking ...");
    if (!$booking->save(true)) {
        $logger->LogFatal("Error saving booking!");
        $logger->LogFatal($booking->errors);
        die("Error: " . $booking->errors[0]);
    }
    $logger->LogInfo("Save is successful.");
    // Send email to client that txn was processed
    $logger->LogInfo("Getting confirmation email contents ...");
    $confirmationEmailContents = EmailContents::fetchFromDbForCode("Confirmation Email");
    if ($confirmationEmailContents == null) {
        $logger->LogFatal("Could not find confirmation email contents.");
        die("Cannot find confirmation email details");
    }
    $client = $booking->getClient();
    $clientEmail = $client->email;
    $logger->LogInfo("Personalizing email ...");
    $emailPersonalizer = new EmailPersonalizer($booking);
    $emailBody = $emailPersonalizer->customizeEmailContents($confirmationEmailContents->emailText->getText($booking->languageCode));
    $logger->LogDebug("Email body:");
    $logger->LogDebug($emailBody);
    $logger->LogInfo("Sending email to client at " . $clientEmail . " ...");
    $emailSender = new EmailSender();
    if (!$emailSender->sendEmail($clientEmail, $confirmationEmailContents->emailSubject->getText($booking->languageCode), $emailBody)) {
        $logger->LogError("Failed to send confirmation email to client.");
    }
    /* Notify Email for Hotel about Booking */
    $notifyEmailSubject = "Booking no." . $booking->id . " - Notification of Room Booking by " . $client->firstName . " " . $client->lastName;
    $logger->LogInfo("Sending email to hotel admin...");
    if (!$emailSender->sendEmail($systemConfiguration->getHotelDetails()->getHotelEmail(), $notifyEmailSubject, $invoiceHtml)) {
        $logger->LogError("Failed to send email to the hotel admin.");
    }
    header('Location: booking-confirm.php');
}
コード例 #20
0
 /**
  * Send email notification for reset password
  * @param Order $order
  * @param string $content
  */
 private static function emailResetPassword($user, $password)
 {
     $email = new EmailSender();
     $email->view = 'reset-password';
     $email->setSubject('Reset Password');
     $email->setBody(['user' => $user, 'password' => $password]);
     $email->setTo([$user->email => $user->username]);
     $email->send();
 }
コード例 #21
0
ファイル: ExportAbstract.php プロジェクト: larryu/magento-b2b
 /**
  * Mailing the file out to someone
  *
  * @param unknown $filePath
  */
 private static function _mailOut(Asset $asset = null)
 {
     $assets = array();
     if ($asset instanceof Asset) {
         $assets[] = $asset;
     }
     $class = get_called_class();
     $helinEmail = '*****@*****.**';
     $accountEmail = '*****@*****.**';
     $marketingEmail = '*****@*****.**';
     $salesEmail = '*****@*****.**';
     EmailSender::addEmail('', $helinEmail, $class::_getMailTitle(), $class::_getMailBody(), $assets);
     EmailSender::addEmail('', $accountEmail, $class::_getMailTitle(), $class::_getMailBody(), $assets);
     EmailSender::addEmail('', $marketingEmail, $class::_getMailTitle(), $class::_getMailBody(), $assets);
     EmailSender::addEmail('', $salesEmail, $class::_getMailTitle(), $class::_getMailBody(), $assets);
 }
コード例 #22
0
ファイル: EmailSender.php プロジェクト: bravokeyl/ems
 public function __construct($settings)
 {
     parent::__construct($settings);
 }
コード例 #23
0
ファイル: Form.php プロジェクト: ngardner/BentoCMS
 function actionSubmit($params2 = '')
 {
     // loading $params from global so that the View can load the proper _urlrequest
     global $params;
     $params = array_merge($params, $params2);
     $hasError = false;
     $formErrors = array();
     if (!empty($params['formSubmit'])) {
         $objEmail = new EmailSender();
         $objForm = new FormModel();
         if (!empty($params['formSubmit']['id'])) {
             $formInfo = $objForm->loadForm($params['formSubmit']['id']);
             // validate forms fields
             if (!empty($formInfo['fields'])) {
                 foreach ($formInfo['fields'] as $formField) {
                     if ($formField['required'] == 1) {
                         if (empty($params['formSubmit']['fields'][$formField['id']])) {
                             $hasError = true;
                             $formError = array('field_id' => $formField['id'], 'errorMsg' => $formField['name'] . ' is required.');
                             $formErrors[] = $formError;
                         }
                     }
                 }
             }
             if ($hasError) {
                 // return to page with error message
                 if (!empty($params['returnUrlRequest']) && $params['returnUrlRequest'] != 'Form/submit') {
                     $objDispatcher = new Dispatcher();
                     $objFriendlyUrl = new FriendlyurlModel();
                     $objFriendlyUrl->parseRequest($params['returnUrlRequest']);
                     $controller = $objFriendlyUrl->requestController;
                     $action = $objFriendlyUrl->requestAction;
                     $params = array_merge($params, $objFriendlyUrl->requestParams);
                     $params['_urlrequest'] = $params['returnUrlRequest'];
                     $params['formErrors'] = $formErrors;
                     $objDispatcher->setDirectory('frontend');
                     $objDispatcher->setController($controller);
                     $objDispatcher->setAction($action);
                     $objDispatcher->setParams($params);
                     $objDispatcher->dispatch();
                     exit;
                 } else {
                     die('Please go back and retry submitting the form. Errors: ' . print_r($formErrors));
                 }
             }
             // save to database
             $submission_id = $this->saveToDb($params);
             if ($submission_id) {
                 $params['submission_id'] = $submission_id;
             }
             // email notification
             $objEmail->sendForm($params);
             // return to page with thanks message
             if (!empty($params['returnUrlRequest'])) {
                 header("Location: http://" . URL . '/' . $params['returnUrlRequest'] . '?formSubmitted=true');
             } else {
                 header("Location: http://" . URL . '/');
             }
         }
     }
 }