/** * Event handler * * @param Event $event calling event * * @return boolean */ function handleEvent(\Cx\Modules\Crm\Model\Entity\CrmEvent $event) { $info = $event->getInfo(); $substitutions = isset($info['substitution']) ? $info['substitution'] : array(); $lang_id = isset($info['lang_id']) ? $info['lang_id'] : FRONTEND_LANG_ID; $arrMailTemplate = array_merge($this->default_info, array('key' => $event->getName(), 'lang_id' => $lang_id, 'substitution' => $substitutions)); if (false === \Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate)) { $event->cancel(); return false; } return true; }
/** * Inform the admin about a reject * * If an email could not be sent, inform the administrator * about that (only if the option to do so was set) * * @param integer $newsletterID Nesletter id * @param integer $userID User Id * @param string $email E-mail id of the user * @param string $type User type * @param array $newsletterUserData Info about the newsletter user */ protected function informAdminAboutRejectedMail($newsletterID, $userID, $email, $type, $newsletterUserData) { global $_CONFIG; // Get the current user's email address $loggedUserMail = \FWUser::getFWUserObject()->objUser->getEmail(); $newsletterValues = $this->getNewsletterValues($newsletterID); $arrMailTemplate = array('key' => 'notify_undelivered_email', 'section' => 'Newsletter', 'lang_id' => BACKEND_LANG_ID, 'to' => $loggedUserMail, 'from' => $newsletterValues['sender_email'], 'sender' => $newsletterValues['sender_name'], 'reply' => $newsletterValues['return_path'], 'substitution' => array('NEWSLETTER_USER_SEX' => $newsletterUserData['sex'], 'NEWSLETTER_USER_TITLE' => $newsletterUserData['title'], 'NEWSLETTER_USER_FIRSTNAME' => $newsletterUserData['firstname'], 'NEWSLETTER_USER_LASTNAME' => $newsletterUserData['lastname'], 'NEWSLETTER_USER_EMAIL' => $newsletterUserData['email'], 'NEWSLETTER_DOMAIN_URL' => $_CONFIG['domainUrl'], 'NEWSLETTER_CURRENT_DATE' => date(ASCMS_DATE_FORMAT), 'NEWSLETTER_SUBJECT' => $newsletterValues['subject'], 'NEWSLETTER_USER_EDIT_LINK' => $this->getUserEditLink($userID, $type))); \Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate); }
/** * Sends the Customer login data * * Note that this only works as expected *after* the Customer has logged * in, but *before* the Customer is redirected to an online payment service * provider, as the session usually gets lost in the process. * So, it's best to call this right after storing the Order, before the * payment transaction is started. * @param string $email The e-mail address * @param string $password The password * @return boolean True on success, false otherwise */ static function sendLogin($email, $password) { global $_ARRAYLANG; $objCustomer = new Customer(); $objCustomer = $objCustomer->getUsers(array('email' => $email)); if (!$objCustomer || $objCustomer->EOF) { return \Message::error($_ARRAYLANG['TXT_SHOP_NO_ACCOUNT_WITH_EMAIL']); } $arrSubstitution = $objCustomer->getSubstitutionArray() + self::getSubstitutionArray(); if (!$arrSubstitution) { return false; } $arrSubstitution['CUSTOMER_LOGIN'][0]['CUSTOMER_PASSWORD'] = $password; // Defaults to FRONTEND_LANG_ID $arrMailTemplate = array('section' => 'Shop', 'key' => 'customer_login', 'substitution' => &$arrSubstitution, 'to' => $objCustomer->email()); return \Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate); }
/** * Send a confirmation e-mail with the order data * * Calls {@see Orders::getSubstitutionArray()}, which en route * creates User accounts for individual electronic Products by default. * Set $create_accounts to false when sending a copy. * @static * @param integer $order_id The order ID * @param boolean $create_accounts Create User accounts for electronic * Products it true * @return boolean The Customers' e-mail address * on success, false otherwise * @access private */ static function sendConfirmationMail($order_id, $create_accounts = true) { $arrSubstitution = Orders::getSubstitutionArray($order_id, $create_accounts); $customer_id = $arrSubstitution['CUSTOMER_ID']; $objCustomer = Customer::getById($customer_id); if (!$objCustomer) { //die("Failed to get Customer for ID $customer_id"); return false; } $arrSubstitution += $objCustomer->getSubstitutionArray() + self::getSubstitutionArray() + array('TIMESTAMP' => date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, date_timestamp_get(date_create())), 'ROOT_URL' => \Cx\Core\Routing\Url::fromDocumentRoot()->toString()); //DBG::log("sendConfirmationMail($order_id, $create_accounts): Subs: ".var_dump($arrSubstitution, true)); if (empty($arrSubstitution)) { return false; } // Prepared template for order confirmation $arrMailTemplate = array('section' => 'Shop', 'key' => 'order_confirmation', 'lang_id' => $arrSubstitution['LANG_ID'], 'to' => $arrSubstitution['CUSTOMER_EMAIL'] . ',' . \Cx\Core\Setting\Controller\Setting::getValue('email_confirmation', 'Shop'), 'substitution' => &$arrSubstitution); //DBG::log("sendConfirmationMail($order_id, $create_accounts): Template: ".var_export($arrMailTemplate, true)); //DBG::log("sendConfirmationMail($order_id, $create_accounts): Substitution: ".var_export($arrSubstitution, true)); // NOTE: Creates some XML order file (for customizing) // $template = file_get_contents( // ASCMS_MODULE_PATH.'/Shop/View/Template/Backend/module_shop_export_orders.xml'); // \Cx\Core\MailTemplate\Controller\MailTemplate::substitute($template, $arrSubstitution, true); // // Strip leftover comments from blocks: "<!---->" or "<!-- -->" // $template = preg_replace('/<!--\s*-->/', '', $template); // $file = new Cx\Lib\FileSystem\File( // ASCMS_DOCUMENT_ROOT.'/orders/'.$order_id.'.xml'); // //$file->makeWritable(); // Fails on win32 // $file->write($template); /// if (!\Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate)) { return false; } return $arrSubstitution['CUSTOMER_EMAIL']; }
/** * Send an e-mail to the Customer with the confirmation that the Order * with the given Order ID has been processed * @param integer $order_id The order ID * @return boolean True on success, false otherwise */ static function sendProcessedMail($order_id) { $arrSubstitution = Orders::getSubstitutionArray($order_id) + self::getSubstitutionArray(); $lang_id = $arrSubstitution['LANG_ID']; // Select template for: "Your order has been processed" $arrMailTemplate = array('section' => 'Shop', 'key' => 'order_complete', 'lang_id' => $lang_id, 'to' => $arrSubstitution['CUSTOMER_EMAIL'], 'substitution' => &$arrSubstitution); if (!\Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate)) { return false; } return $arrSubstitution['CUSTOMER_EMAIL']; }
/** * Send notification mail * * @param integer $action 1 = subscribe | 2 = unsubscribe * @param integer $recipientId Id of the recipient * * @return boolean True when notification mail send successfully, false otherwise */ function _sendNotificationEmail($action, $recipientId) { global $_CONFIG, $_ARRAYLANG, $objDatabase; //action: 1 = subscribe | 2 = unsubscribe $objSettings = $objDatabase->Execute("SELECT `setname`, `setvalue` FROM `" . DBPREFIX . "module_newsletter_settings` WHERE `setname` = 'notificationSubscribe' OR `setname` = 'notificationUnsubscribe' "); if ($objSettings !== false) { while (!$objSettings->EOF) { $arrSettings[$objSettings->fields['setname']] = $objSettings->fields['setvalue']; $objSettings->MoveNext(); } } if ($arrSettings['notificationSubscribe'] == 1 && $action == 1 || $arrSettings['notificationUnsubscribe'] == 1 && $action == 2) { $objRecipient = $objDatabase->SelectLimit("SELECT sex, salutation, lastname, firstname, email FROM " . DBPREFIX . "module_newsletter_user WHERE id=" . $recipientId, 1); if ($objRecipient !== false) { $arrRecipient['sex'] = $objRecipient->fields['sex']; $arrRecipient['salutation'] = $objRecipient->fields['salutation']; $arrRecipient['lastname'] = $objRecipient->fields['lastname']; $arrRecipient['firstname'] = $objRecipient->fields['firstname']; $arrRecipient['email'] = $objRecipient->fields['email']; } $objRecipientTitle = $objDatabase->SelectLimit("SELECT title FROM " . DBPREFIX . "module_newsletter_user_title WHERE id=" . $arrRecipient['salutation'], 1); if ($objRecipientTitle !== false) { $arrRecipientTitle = $objRecipientTitle->fields['title']; } $notifyMails = array(); if ($action == 1) { $txtAction = $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_SUBSCRIBE']; } else { $txtAction = $_ARRAYLANG['TXT_NEWSLETTER_NOTIFICATION_UNSUBSCRIBE']; $objNotificationAdressesFromLists = $objDatabase->Execute('SELECT notification_email FROM ' . DBPREFIX . 'module_newsletter_category AS c INNER JOIN ' . DBPREFIX . 'module_newsletter_rel_user_cat AS r ON r.category = c.id WHERE r.user = '******',', $objNotificationAdressesFromLists->fields['notification_email']) as $mail) { if (!in_array($mail, $notifyMails)) { array_push($notifyMails, trim($mail)); } } $objNotificationAdressesFromLists->MoveNext(); } } } $arrSettings = $this->_getSettings(); $arrMailTemplate = array('key' => 'notification_email', 'section' => 'Newsletter', 'lang_id' => FRONTEND_LANG_ID, 'to' => implode(',', $notifyMails), 'from' => $arrSettings['sender_mail']['setvalue'], 'sender' => $arrSettings['sender_name']['setvalue'], 'reply' => $arrSettings['reply_mail']['setvalue'], 'substitution' => array('NEWSLETTER_NOTIFICATION_ACTION' => $txtAction, 'NEWSLETTER_USER_SEX' => $arrRecipient['sex'], 'NEWSLETTER_USER_TITLE' => $arrRecipientTitle, 'NEWSLETTER_USER_FIRSTNAME' => $arrRecipient['firstname'], 'NEWSLETTER_USER_LASTNAME' => $arrRecipient['lastname'], 'NEWSLETTER_USER_EMAIL' => $arrRecipient['email'], 'NEWSLETTER_DOMAIN_URL' => $_CONFIG['domainUrl'], 'NEWSLETTER_CURRENT_DATE' => date(ASCMS_DATE_FORMAT))); if (!\Cx\Core\MailTemplate\Controller\MailTemplate::send($arrMailTemplate)) { return false; } return true; } // TODO: This used to return *nothing* when notifications were turned off. // Probably true should be returned in this case instead. // -- See the condition way above. return false; }