00001 <?php
00005 require oxRegistry::getConfig()->getConfigParam('sCoreDir') . "/phpmailer/class.phpmailer.php";
00006
00007
00013 class oxEmail extends PHPMailer
00014 {
00015
00021 public $SMTP_PORT = 25;
00022
00028 protected $_sForgotPwdTemplate = "email/html/forgotpwd.tpl";
00029
00035 protected $_sForgotPwdTemplatePlain = "email/plain/forgotpwd.tpl";
00036
00042 protected $_sNewsletterOptInTemplate = "email/html/newsletteroptin.tpl";
00043
00049 protected $_sNewsletterOptInTemplatePlain = "email/plain/newsletteroptin.tpl";
00050
00056 protected $_sSuggestTemplate = "email/html/suggest.tpl";
00057
00063 protected $_sSuggestTemplatePlain = "email/plain/suggest.tpl";
00064
00070 protected $_sInviteTemplate = "email/html/invite.tpl";
00071
00077 protected $_sInviteTemplatePlain = "email/plain/invite.tpl";
00078
00084 protected $_sSenedNowTemplate = "email/html/ordershipped.tpl";
00085
00091 protected $_sSenedNowTemplatePlain = "email/plain/ordershipped.tpl";
00092
00098 protected $_sSendDownloadsTemplate = "email/html/senddownloadlinks.tpl";
00099
00105 protected $_sSendDownloadsTemplatePlain = "email/plain/senddownloadlinks.tpl";
00106
00112 protected $_sWishListTemplate = "email/html/wishlist.tpl";
00113
00119 protected $_sWishListTemplatePlain = "email/plain/wishlist.tpl";
00120
00126 protected $_sRegisterTemplate = "email/html/register.tpl";
00127
00133 protected $_sRegisterTemplatePlain = "email/plain/register.tpl";
00134
00140 protected $_sReminderMailTemplate = "email/html/owner_reminder.tpl";
00141
00147 protected $_sOrderUserTemplate = "email/html/order_cust.tpl";
00148
00154 protected $_sOrderUserPlainTemplate = "email/plain/order_cust.tpl";
00155
00161 protected $_sOrderOwnerTemplate = "email/html/order_owner.tpl";
00162
00168 protected $_sOrderOwnerPlainTemplate = "email/plain/order_owner.tpl";
00169
00170
00171
00177 protected $_sOrderUserSubjectTemplate = "email/html/order_cust_subj.tpl";
00178
00184 protected $_sOrderOwnerSubjectTemplate = "email/html/order_owner_subj.tpl";
00185
00191 protected $_sOwnerPricealarmTemplate = "email/html/pricealarm_owner.tpl";
00192
00198 protected $_sPricealamrCustomerTemplate = "email_pricealarm_customer.tpl";
00199
00205 protected $_aShops = array();
00206
00212 protected $_blInlineImgEmail = null;
00213
00219 protected $_aRecipients = array();
00220
00226 protected $_aReplies = array();
00227
00233 protected $_aAttachments = array();
00234
00240 protected $_oSmarty = null;
00241
00247 protected $_aViewData = array();
00248
00254 protected $_oShop = null;
00255
00261 protected $_sCharSet = null;
00262
00266 public function __construct()
00267 {
00268
00269 parent::__construct(true);
00270
00271 $myConfig = $this->getConfig();
00272
00273 $this->_setMailerPluginDir();
00274 $this->setSmtp();
00275
00276 $this->setUseInlineImages($myConfig->getConfigParam('blInlineImgEmail'));
00277 $this->setMailWordWrap(100);
00278
00279 $this->isHtml(true);
00280 $this->setLanguage("en", $myConfig->getConfigParam('sShopDir') . "/core/phpmailer/language/");
00281
00282 $this->_getSmarty();
00283 }
00284
00296 public function __call($sMethod, $aArgs)
00297 {
00298 if (defined('OXID_PHP_UNIT')) {
00299 if (substr($sMethod, 0, 4) == "UNIT") {
00300 $sMethod = str_replace("UNIT", "_", $sMethod);
00301 }
00302 if (method_exists($this, $sMethod)) {
00303 return call_user_func_array(array(& $this, $sMethod), $aArgs);
00304 }
00305 }
00306
00307 throw new oxSystemComponentException("Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")" . PHP_EOL);
00308 }
00309
00315 public function getConfig()
00316 {
00317 if ($this->_oConfig == null) {
00318 $this->_oConfig = oxRegistry::getConfig();
00319 }
00320
00321 return $this->_oConfig;
00322 }
00323
00329 public function setConfig($oConfig)
00330 {
00331 $this->_oConfig = $oConfig;
00332 }
00333
00334
00340 protected function _getSmarty()
00341 {
00342 if ($this->_oSmarty === null) {
00343 $this->_oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00344 }
00345
00346
00347 $this->_oSmarty->assign("oEmailView", $this);
00348
00349 return $this->_oSmarty;
00350 }
00351
00359 public function send()
00360 {
00361
00362 if (count($this->getRecipient()) < 1) {
00363 return false;
00364 }
00365
00366 $myConfig = $this->getConfig();
00367 $this->setCharSet();
00368
00369 if ($this->_getUseInlineImages()) {
00370 $this->_includeImages(
00371 $myConfig->getImageDir(), $myConfig->getImageUrl(false, false), $myConfig->getPictureUrl(null, false),
00372 $myConfig->getImageDir(), $myConfig->getPictureDir(false)
00373 );
00374 }
00375
00376 $this->_makeOutputProcessing();
00377
00378
00379 if ($this->getMailer() == 'smtp') {
00380 $blRet = $this->_sendMail();
00381
00382
00383 if (!$blRet) {
00384
00385 $this->_sendMailErrorMsg();
00386
00387
00388 $this->setMailer('mail');
00389 $blRet = $this->_sendMail();
00390 }
00391 } else {
00392
00393 $this->setMailer('mail');
00394 $blRet = $this->_sendMail();
00395 }
00396
00397 if (!$blRet) {
00398
00399 $this->_sendMailErrorMsg();
00400 }
00401
00402 return $blRet;
00403 }
00404
00413 protected function _setSmtpProtocol($sUrl)
00414 {
00415 $sProtocol = '';
00416 $sSmtpHost = $sUrl;
00417 $aMatch = array();
00418 if (getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $aMatch)) {
00419 if ($aMatch[1]) {
00420 if (($aMatch[1] == 'ssl://') || ($aMatch[1] == 'tls://')) {
00421 $this->set("SMTPSecure", substr($aMatch[1], 0, 3));
00422 } else {
00423 $sProtocol = $aMatch[1];
00424 }
00425 }
00426 $sSmtpHost = $aMatch[2];
00427 }
00428
00429 return $sProtocol . $sSmtpHost;
00430 }
00431
00439 public function setSmtp($oShop = null)
00440 {
00441 $myConfig = $this->getConfig();
00442 $oShop = ($oShop) ? $oShop : $this->_getShop();
00443
00444 $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00445
00446 if (!$this->_isValidSmtpHost($sSmtpUrl)) {
00447 $this->setMailer("mail");
00448
00449 return;
00450 }
00451
00452 $this->setHost($sSmtpUrl);
00453 $this->setMailer("smtp");
00454
00455 if ($oShop->oxshops__oxsmtpuser->value) {
00456 $this->_setSmtpAuthInfo($oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value);
00457 }
00458
00459 if ($myConfig->getConfigParam('iDebug') == 6) {
00460 $this->_setSmtpDebug(true);
00461 }
00462 }
00463
00471 protected function _isValidSmtpHost($sSmtpHost)
00472 {
00473 $blIsSmtp = false;
00474 if ($sSmtpHost) {
00475 $sSmtpPort = $this->SMTP_PORT;
00476 $aMatch = array();
00477 if (getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $aMatch)) {
00478 $sSmtpHost = $aMatch[1];
00479 $sSmtpPort = (int) $aMatch[3];
00480 if (!$sSmtpPort) {
00481 $sSmtpPort = $this->SMTP_PORT;
00482 }
00483 }
00484 if ($blIsSmtp = (bool) ($rHandle = @fsockopen($sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30))) {
00485
00486 fclose($rHandle);
00487 }
00488 }
00489
00490 return $blIsSmtp;
00491 }
00492
00502 public function sendOrderEmailToUser($oOrder, $sSubject = null)
00503 {
00504 $myConfig = $this->getConfig();
00505
00506
00507 $oOrder = $this->_addUserInfoOrderEMail($oOrder);
00508
00509 $oShop = $this->_getShop();
00510 $this->_setMailParams($oShop);
00511
00512 $oUser = $oOrder->getOrderUser();
00513 $this->setUser($oUser);
00514
00515
00516 $oSmarty = $this->_getSmarty();
00517 $this->setViewData("order", $oOrder);
00518
00519 if ($myConfig->getConfigParam("bl_perfLoadReviews")) {
00520 $this->setViewData("blShowReviewLink", true);
00521 }
00522
00523
00524 $this->_processViewArray();
00525
00526 $this->setBody($oSmarty->fetch($this->_sOrderUserTemplate));
00527 $this->setAltBody($oSmarty->fetch($this->_sOrderUserPlainTemplate));
00528
00529
00530 if ($sSubject === null) {
00531 if ($oSmarty->template_exists($this->_sOrderUserSubjectTemplate)) {
00532 $sSubject = $oSmarty->fetch($this->_sOrderUserSubjectTemplate);
00533 } else {
00534 $sSubject = $oShop->oxshops__oxordersubject->getRawValue() . " (#" . $oOrder->oxorder__oxordernr->value . ")";
00535 }
00536 }
00537
00538 $this->setSubject($sSubject);
00539
00540 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00541
00542 $this->setRecipient($oUser->oxuser__oxusername->value, $sFullName);
00543 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
00544
00545 $blSuccess = $this->send();
00546
00547 return $blSuccess;
00548 }
00549
00559 public function sendOrderEmailToOwner($oOrder, $sSubject = null)
00560 {
00561 $myConfig = $this->getConfig();
00562
00563 $oShop = $this->_getShop();
00564
00565
00566 $this->_clearMailer();
00567
00568
00569 $oOrder = $this->_addUserInfoOrderEMail($oOrder);
00570
00571 $oUser = $oOrder->getOrderUser();
00572 $this->setUser($oUser);
00573
00574
00575
00576 $this->setFrom($oShop->oxshops__oxowneremail->value);
00577
00578 $oLang = oxRegistry::getLang();
00579 $iOrderLang = $oLang->getObjectTplLanguage();
00580
00581
00582
00583 if ($oShop->getLanguage() != $iOrderLang) {
00584 $oShop = $this->_getShop($iOrderLang);
00585 }
00586
00587 $this->setSmtp($oShop);
00588
00589
00590 $oSmarty = $this->_getSmarty();
00591 $this->setViewData("order", $oOrder);
00592
00593
00594 $this->_processViewArray();
00595
00596 $this->setBody($oSmarty->fetch($myConfig->getTemplatePath($this->_sOrderOwnerTemplate, false)));
00597 $this->setAltBody($oSmarty->fetch($myConfig->getTemplatePath($this->_sOrderOwnerPlainTemplate, false)));
00598
00599
00600
00601 if ($sSubject === null) {
00602 if ($oSmarty->template_exists($this->_sOrderOwnerSubjectTemplate)) {
00603 $sSubject = $oSmarty->fetch($this->_sOrderOwnerSubjectTemplate);
00604 } else {
00605 $sSubject = $oShop->oxshops__oxordersubject->getRawValue() . " (#" . $oOrder->oxorder__oxordernr->value . ")";
00606 }
00607 }
00608
00609 $this->setSubject($sSubject);
00610 $this->setRecipient($oShop->oxshops__oxowneremail->value, $oLang->translateString("order"));
00611
00612 if ($oUser->oxuser__oxusername->value != "admin") {
00613 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00614 $this->setReplyTo($oUser->oxuser__oxusername->value, $sFullName);
00615 }
00616
00617 $blSuccess = $this->send();
00618
00619
00620 $oRemark = oxNew("oxremark");
00621 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00622 $oRemark->oxremark__oxparentid = new oxField($oUser->getId(), oxField::T_RAW);
00623 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00624 $oRemark->save();
00625
00626
00627 if ($myConfig->getConfigParam('iDebug') == 6) {
00628 oxRegistry::getUtils()->showMessageAndExit("");
00629 }
00630
00631 return $blSuccess;
00632 }
00633
00643 public function sendRegisterConfirmEmail($oUser, $sSubject = null)
00644 {
00645
00646
00647 $this->setViewData("contentident", "oxregisteraltemail");
00648 $this->setViewData("contentplainident", "oxregisterplainaltemail");
00649
00650
00651 return $this->sendRegisterEmail($oUser, $sSubject);
00652 }
00653
00663 public function sendRegisterEmail($oUser, $sSubject = null)
00664 {
00665
00666 $oUser = $this->_addUserRegisterEmail($oUser);
00667
00668
00669 $oShop = $this->_getShop();
00670
00671
00672 $this->_setMailParams($oShop);
00673
00674
00675 $oSmarty = $this->_getSmarty();
00676 $this->setUser($oUser);
00677
00678
00679 $this->_processViewArray();
00680
00681 $this->setBody($oSmarty->fetch($this->_sRegisterTemplate));
00682 $this->setAltBody($oSmarty->fetch($this->_sRegisterTemplatePlain));
00683
00684 $this->setSubject(($sSubject !== null) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue());
00685
00686 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00687
00688 $this->setRecipient($oUser->oxuser__oxusername->value, $sFullName);
00689 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
00690
00691 return $this->send();
00692 }
00693
00703 public function sendForgotPwdEmail($sEmailAddress, $sSubject = null)
00704 {
00705 $myConfig = $this->getConfig();
00706 $oDb = oxDb::getDb();
00707
00708
00709 $oShop = $this->_getShop();
00710
00711
00712 $oShop = $this->_addForgotPwdEmail($oShop);
00713
00714
00715 $this->_setMailParams($oShop);
00716
00717
00718 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = " . $oDb->quote($sEmailAddress) . " and oxuser.oxpassword != ''";
00719 $sOrder = "";
00720 if ($myConfig->getConfigParam('blMallUsers')) {
00721 $sOrder = "order by oxshopid = '" . $oShop->getId() . "' desc";
00722 } else {
00723 $sWhere .= " and oxshopid = '" . $oShop->getId() . "'";
00724 }
00725
00726 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00727 if (($sOxId = $oDb->getOne($sSelect))) {
00728
00729 $oUser = oxNew('oxuser');
00730 if ($oUser->load($sOxId)) {
00731
00732 $oSmarty = $this->_getSmarty();
00733 $this->setUser($oUser);
00734
00735
00736 $this->_processViewArray();
00737
00738 $this->setBody($oSmarty->fetch($this->_sForgotPwdTemplate));
00739
00740 $this->setAltBody($oSmarty->fetch($this->_sForgotPwdTemplatePlain));
00741
00742
00743 $this->setSubject(($sSubject !== null) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue());
00744
00745 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00746
00747 $this->setRecipient($sEmailAddress, $sFullName);
00748 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
00749
00750 if (!$this->send()) {
00751 return -1;
00752 }
00753
00754 return true;
00755 }
00756 }
00757
00758 return false;
00759 }
00760
00771 public function sendContactMail($sEmailAddress = null, $sSubject = null, $sMessage = null)
00772 {
00773
00774
00775 $oShop = $this->_getShop();
00776
00777
00778 $this->_setMailParams($oShop);
00779
00780 $this->setBody($sMessage);
00781 $this->setSubject($sSubject);
00782
00783 $this->setRecipient($oShop->oxshops__oxinfoemail->value, "");
00784 $this->setFrom($oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue());
00785 $this->setReplyTo($sEmailAddress, "");
00786
00787 return $this->send();
00788 }
00789
00799 public function sendNewsletterDbOptInMail($oUser, $sSubject = null)
00800 {
00801 $oLang = oxRegistry::getLang();
00802
00803
00804 $oUser = $this->_addNewsletterDbOptInMail($oUser);
00805
00806
00807 $oShop = $this->_getShop();
00808
00809
00810 $this->_setMailParams($oShop);
00811
00812
00813 $oSmarty = $this->_getSmarty();
00814 $sConfirmCode = md5($oUser->oxuser__oxusername->value . $oUser->oxuser__oxpasssalt->value);
00815 $this->setViewData("subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value, $sConfirmCode));
00816 $this->setUser($oUser);
00817
00818
00819 $this->_processViewArray();
00820
00821 $this->setBody($oSmarty->fetch($this->_sNewsletterOptInTemplate));
00822 $this->setAltBody($oSmarty->fetch($this->_sNewsletterOptInTemplatePlain));
00823 $this->setSubject(($sSubject !== null) ? $sSubject : oxRegistry::getLang()->translateString("NEWSLETTER") . " " . $oShop->oxshops__oxname->getRawValue());
00824
00825 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00826
00827 $this->setRecipient($oUser->oxuser__oxusername->value, $sFullName);
00828 $this->setFrom($oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue());
00829 $this->setReplyTo($oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue());
00830
00831 return $this->send();
00832 }
00833
00842 protected function _getNewsSubsLink($sId, $sConfirmCode = null)
00843 {
00844 $myConfig = $this->getConfig();
00845 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00846
00847 $sUrl = $myConfig->getShopHomeURL() . 'cl=newsletter&fnc=addme&uid=' . $sId;
00848 $sUrl .= '&lang=' . $iActShopLang;
00849 $sUrl .= ($sConfirmCode) ? '&confirm=' . $sConfirmCode : "";
00850
00851 return $sUrl;
00852 }
00853
00864 public function sendNewsletterMail($oNewsLetter, $oUser, $sSubject = null)
00865 {
00866
00867 $oShop = $this->_getShop();
00868
00869
00870 $this->_setMailParams($oShop);
00871
00872 $sBody = $oNewsLetter->getHtmlText();
00873
00874 if (!empty($sBody)) {
00875 $this->setBody($sBody);
00876 $this->setAltBody($oNewsLetter->getPlainText());
00877 } else {
00878 $this->isHtml(false);
00879 $this->setBody($oNewsLetter->getPlainText());
00880 }
00881
00882 $this->setSubject(($sSubject !== null) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue());
00883
00884 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00885 $this->setRecipient($oUser->oxuser__oxusername->value, $sFullName);
00886 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
00887
00888 return $this->send();
00889 }
00890
00891
00901 public function sendSuggestMail($oParams, $oProduct)
00902 {
00903 $myConfig = $this->getConfig();
00904
00905
00906 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00907
00908
00909 $oShop = $this->_getShop($iCurrLang);
00910
00911
00912 if ($oProduct->getLanguage() != $iCurrLang) {
00913 $oProduct->setLanguage($iCurrLang);
00914 $oProduct->load($oProduct->getId());
00915 }
00916
00917
00918
00919 $this->setFrom($oShop->oxshops__oxinfoemail->value);
00920 $this->setSMTP();
00921
00922
00923 $oSmarty = $this->_getSmarty();
00924 $this->setViewData("product", $oProduct);
00925 $this->setUser($oParams);
00926
00927 $sArticleUrl = $oProduct->getLink();
00928
00929
00930 if ($myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser()) {
00931 $sArticleUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator($sArticleUrl);
00932 $sArticleUrl .= "su=" . $oActiveUser->getId();
00933 }
00934
00935 $this->setViewData("sArticleUrl", $sArticleUrl);
00936
00937
00938 $this->_processViewArray();
00939
00940 $this->setBody($oSmarty->fetch($this->_sSuggestTemplate));
00941 $this->setAltBody($oSmarty->fetch($this->_sSuggestTemplatePlain));
00942 $this->setSubject($oParams->send_subject);
00943
00944 $this->setRecipient($oParams->rec_email, $oParams->rec_name);
00945 $this->setReplyTo($oParams->send_email, $oParams->send_name);
00946
00947 return $this->send();
00948 }
00949
00958 public function sendInviteMail($oParams)
00959 {
00960 $myConfig = $this->getConfig();
00961
00962
00963 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00964
00965
00966 $oShop = $this->_getShop($iCurrLang);
00967
00968
00969 $this->setFrom($oParams->send_email, $oParams->send_name);
00970 $this->setSMTP();
00971
00972
00973 $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00974 $this->setUser($oParams);
00975
00976 $sHomeUrl = $this->getViewConfig()->getHomeLink();
00977
00978
00979 if ($myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser()) {
00980 $sHomeUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator($sHomeUrl);
00981 $sHomeUrl .= "su=" . $oActiveUser->getId();
00982 }
00983
00984 if (is_array($oParams->rec_email) && count($oParams->rec_email) > 0) {
00985 foreach ($oParams->rec_email as $sEmail) {
00986 if (!empty($sEmail)) {
00987 $sRegisterUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator($sHomeUrl);
00988
00989 $sRegisterUrl .= "re=" . md5($sEmail);
00990 $this->setViewData("sHomeUrl", $sRegisterUrl);
00991
00992
00993 $this->_processViewArray();
00994
00995 $this->setBody($oSmarty->fetch($this->_sInviteTemplate));
00996
00997 $this->setAltBody($oSmarty->fetch($this->_sInviteTemplatePlain));
00998 $this->setSubject($oParams->send_subject);
00999
01000 $this->setRecipient($sEmail);
01001 $this->setReplyTo($oParams->send_email, $oParams->send_name);
01002 $this->send();
01003 $this->clearAllRecipients();
01004 }
01005 }
01006
01007 return true;
01008 }
01009
01010 return false;
01011 }
01012
01022 public function sendSendedNowMail($oOrder, $sSubject = null)
01023 {
01024 $myConfig = $this->getConfig();
01025
01026 $iOrderLang = (int) (isset($oOrder->oxorder__oxlang->value) ? $oOrder->oxorder__oxlang->value : 0);
01027
01028
01029 $oShop = $this->_getShop($iOrderLang);
01030
01031
01032 $this->_setMailParams($oShop);
01033
01034
01035 $oLang = oxRegistry::getLang();
01036 $oSmarty = $this->_getSmarty();
01037 $this->setViewData("order", $oOrder);
01038 $this->setViewData("shopTemplateDir", $myConfig->getTemplateDir(false));
01039
01040 if ($myConfig->getConfigParam("bl_perfLoadReviews")) {
01041 $this->setViewData("blShowReviewLink", true);
01042 $oUser = oxNew('oxuser');
01043 $this->setViewData("reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value));
01044 }
01045
01046
01047 $this->_processViewArray();
01048
01049
01050 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01051
01052 $iOldTplLang = $oLang->getTplLanguage();
01053 $iOldBaseLang = $oLang->getTplLanguage();
01054 $oLang->setTplLanguage($iOrderLang);
01055 $oLang->setBaseLanguage($iOrderLang);
01056
01057 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01058
01059 $myConfig->setAdminMode(false);
01060 $this->setBody($oSmarty->fetch($this->_sSenedNowTemplate));
01061 $this->setAltBody($oSmarty->fetch($this->_sSenedNowTemplatePlain));
01062 $myConfig->setAdminMode(true);
01063 $oLang->setTplLanguage($iOldTplLang);
01064 $oLang->setBaseLanguage($iOldBaseLang);
01065
01066 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'];
01067
01068
01069 $this->setSubject(($sSubject !== null) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue());
01070
01071 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01072
01073 $this->setRecipient($oOrder->oxorder__oxbillemail->value, $sFullName);
01074 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
01075
01076 return $this->send();
01077 }
01078
01088 public function sendDownloadLinksMail($oOrder, $sSubject = null)
01089 {
01090 $myConfig = $this->getConfig();
01091
01092 $iOrderLang = (int) (isset($oOrder->oxorder__oxlang->value) ? $oOrder->oxorder__oxlang->value : 0);
01093
01094
01095 $oShop = $this->_getShop($iOrderLang);
01096
01097
01098 $this->_setMailParams($oShop);
01099
01100
01101 $oLang = oxRegistry::getLang();
01102 $oSmarty = $this->_getSmarty();
01103 $this->setViewData("order", $oOrder);
01104 $this->setViewData("shopTemplateDir", $myConfig->getTemplateDir(false));
01105
01106 $oUser = oxNew('oxuser');
01107 $this->setViewData("reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value));
01108
01109
01110 $this->_processViewArray();
01111
01112
01113 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01114
01115 $iOldTplLang = $oLang->getTplLanguage();
01116 $iOldBaseLang = $oLang->getTplLanguage();
01117 $oLang->setTplLanguage($iOrderLang);
01118 $oLang->setBaseLanguage($iOrderLang);
01119
01120 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01121
01122 $myConfig->setAdminMode(false);
01123 $this->setBody($oSmarty->fetch($this->_sSendDownloadsTemplate));
01124 $this->setAltBody($oSmarty->fetch($this->_sSendDownloadsTemplatePlain));
01125 $myConfig->setAdminMode(true);
01126 $oLang->setTplLanguage($iOldTplLang);
01127 $oLang->setBaseLanguage($iOldBaseLang);
01128
01129 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'];
01130
01131
01132 $this->setSubject(($sSubject !== null) ? $sSubject : $oLang->translateString("DOWNLOAD_LINKS", null, false));
01133
01134 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01135
01136 $this->setRecipient($oOrder->oxorder__oxbillemail->value, $sFullName);
01137 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
01138
01139 return $this->send();
01140 }
01141
01156 public function sendBackupMail($aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError)
01157 {
01158
01159 $oShop = $this->_getShop();
01160
01161
01162 $this->_setMailParams($oShop);
01163
01164 $this->setBody($sMessage);
01165 $this->setSubject($sSubject);
01166
01167 $this->setRecipient($oShop->oxshops__oxinfoemail->value, "");
01168 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01169
01170 $this->setFrom($sEmailAddress, "");
01171 $this->setReplyTo($sEmailAddress, "");
01172
01173
01174 $blAttashSucc = true;
01175 $sAttPath = oxRegistry::get("oxUtilsFile")->normalizeDir($sAttPath);
01176 foreach ($aAttFiles as $iNum => $sAttFile) {
01177 $sFullPath = $sAttPath . $sAttFile;
01178 if (@is_readable($sFullPath) && @is_file($sFullPath)) {
01179 $blAttashSucc = $this->addAttachment($sFullPath, $sAttFile);
01180 } else {
01181 $blAttashSucc = false;
01182 $aError[] = array(5, $sAttFile);
01183 }
01184 }
01185
01186 if (!$blAttashSucc) {
01187 $aError[] = array(4, "");
01188 $this->clearAttachments();
01189
01190 return false;
01191 }
01192
01193 $aStatus[] = 3;
01194 $blSend = $this->send();
01195 $this->clearAttachments();
01196
01197 return $blSend;
01198 }
01199
01210 public function sendEmail($sTo, $sSubject, $sBody)
01211 {
01212
01213 $this->_setMailParams();
01214
01215 if (is_array($sTo)) {
01216 foreach ($sTo as $sAddress) {
01217 $this->setRecipient($sAddress, "");
01218 $this->setReplyTo($sAddress, "");
01219 }
01220 } else {
01221 $this->setRecipient($sTo, "");
01222 $this->setReplyTo($sTo, "");
01223 }
01224
01225
01226 $this->isHtml(false);
01227
01228 $this->setSubject($sSubject);
01229 $this->setBody($sBody);
01230
01231 return $this->send();
01232 }
01233
01242 public function sendStockReminder($aBasketContents, $sSubject = null)
01243 {
01244 $blSend = false;
01245
01246 $oArticleList = oxNew("oxarticlelist");
01247 $oArticleList->loadStockRemindProducts($aBasketContents);
01248
01249
01250 if ($oArticleList->count()) {
01251 $oShop = $this->_getShop();
01252
01253
01254 $this->_setMailParams($oShop);
01255 $oLang = oxRegistry::getLang();
01256
01257 $oSmarty = $this->_getSmarty();
01258 $this->setViewData("articles", $oArticleList);
01259
01260
01261 $this->_processViewArray();
01262
01263 $this->setRecipient($oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue());
01264 $this->setFrom($oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue());
01265 $this->setBody($oSmarty->fetch($this->getConfig()->getTemplatePath($this->_sReminderMailTemplate, false)));
01266 $this->setAltBody("");
01267 $this->setSubject(($sSubject !== null) ? $sSubject : $oLang->translateString('STOCK_LOW'));
01268
01269 $blSend = $this->send();
01270 }
01271
01272 return $blSend;
01273 }
01274
01283 public function sendWishlistMail($oParams)
01284 {
01285 $myConfig = $this->getConfig();
01286
01287 $this->_clearMailer();
01288
01289
01290 $oShop = $this->_getShop();
01291
01292
01293 $this->setFrom($oParams->send_email, $oParams->send_name);
01294 $this->setSMTP();
01295
01296
01297 $oSmarty = $this->_getSmarty();
01298 $this->setUser($oParams);
01299
01300
01301 $this->_processViewArray();
01302
01303 $this->setBody($oSmarty->fetch($this->_sWishListTemplate));
01304 $this->setAltBody($oSmarty->fetch($this->_sWishListTemplatePlain));
01305 $this->setSubject($oParams->send_subject);
01306
01307 $this->setRecipient($oParams->rec_email, $oParams->rec_name);
01308 $this->setReplyTo($oParams->send_email, $oParams->send_name);
01309
01310 return $this->send();
01311 }
01312
01323 public function sendPriceAlarmNotification($aParams, $oAlarm, $sSubject = null)
01324 {
01325 $this->_clearMailer();
01326 $oShop = $this->_getShop();
01327
01328
01329 $this->_setMailParams($oShop);
01330
01331 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01332
01333 $oArticle = oxNew("oxarticle");
01334
01335 $oArticle->loadInLang($iAlarmLang, $aParams['aid']);
01336 $oLang = oxRegistry::getLang();
01337
01338
01339 $oSmarty = $this->_getSmarty();
01340 $this->setViewData("product", $oArticle);
01341 $this->setViewData("email", $aParams['email']);
01342 $this->setViewData("bidprice", $oLang->formatCurrency($oAlarm->oxpricealarm__oxprice->value, $oCur));
01343
01344
01345 $this->_processViewArray();
01346
01347 $this->setRecipient($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
01348 $this->setSubject(($sSubject !== null) ? $sSubject : $oLang->translateString('PRICE_ALERT_FOR_PRODUCT', $iAlarmLang) . " " . $oArticle->oxarticles__oxtitle->getRawValue());
01349 $this->setBody($oSmarty->fetch($this->_sOwnerPricealarmTemplate));
01350 $this->setFrom($aParams['email'], "");
01351 $this->setReplyTo($aParams['email'], "");
01352
01353 return $this->send();
01354 }
01355
01367 public function sendPricealarmToCustomer($sRecipient, $oAlarm, $sBody = null, $sReturnMailBody = null)
01368 {
01369 $this->_clearMailer();
01370
01371 $oShop = $this->_getShop();
01372
01373 if ($oShop->getId() != $oAlarm->oxpricealarm__oxshopid->value) {
01374 $oShop = oxNew("oxshop");
01375 $oShop->load($oAlarm->oxpricealarm__oxshopid->value);
01376 $this->setShop($oShop);
01377 }
01378
01379
01380 $this->_setMailParams($oShop);
01381
01382
01383 $oSmarty = $this->_getSmarty();
01384
01385 $this->setViewData("product", $oAlarm->getArticle());
01386 $this->setViewData("oPriceAlarm", $oAlarm);
01387 $this->setViewData("bidprice", $oAlarm->getFProposedPrice());
01388 $this->setViewData("currency", $oAlarm->getPriceAlarmCurrency());
01389
01390
01391 $this->_processViewArray();
01392
01393 $this->setRecipient($sRecipient, $sRecipient);
01394 $this->setSubject($oShop->oxshops__oxname->value);
01395
01396 if ($sBody === null) {
01397 $sBody = $oSmarty->fetch($this->_sPricealamrCustomerTemplate);
01398 }
01399
01400 $this->setBody($sBody);
01401
01402 $this->addAddress($sRecipient, $sRecipient);
01403 $this->setReplyTo($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
01404
01405 if ($sReturnMailBody) {
01406 return $this->getBody();
01407 } else {
01408 return $this->send();
01409 }
01410 }
01411
01421 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01422 {
01423 $sBody = $this->getBody();
01424 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01425
01426 $oFileUtils = oxRegistry::get("oxUtilsFile");
01427 $blReSetBody = false;
01428
01429
01430 $sDynImageDir = $oFileUtils->normalizeDir($sDynImageDir);
01431 $sImageDir = $oFileUtils->normalizeDir($sImageDir);
01432 $sImageDirNoSSL = $oFileUtils->normalizeDir($sImageDirNoSSL);
01433
01434 if (is_array($matches) && count($matches)) {
01435 $aImageCache = array();
01436 $myUtils = oxRegistry::getUtils();
01437 $myUtilsObject = oxUtilsObject::getInstance();
01438 $oImgGenerator = oxNew("oxDynImgGenerator");
01439
01440 foreach ($matches as $aImage) {
01441
01442 $image = $aImage[1];
01443 $sFileName = '';
01444 if (strpos($image, $sDynImageDir) === 0) {
01445 $sFileName = $oFileUtils->normalizeDir($sAbsDynImageDir) . str_replace($sDynImageDir, '', $image);
01446 } elseif (strpos($image, $sImageDir) === 0) {
01447 $sFileName = $oFileUtils->normalizeDir($sAbsImageDir) . str_replace($sImageDir, '', $image);
01448 } elseif (strpos($image, $sImageDirNoSSL) === 0) {
01449 $sFileName = $oFileUtils->normalizeDir($sAbsImageDir) . str_replace($sImageDirNoSSL, '', $image);
01450 }
01451
01452 if ($sFileName && !@is_readable($sFileName)) {
01453 $sFileName = $oImgGenerator->getImagePath($sFileName);
01454 }
01455
01456 if ($sFileName) {
01457 $sCId = '';
01458 if (isset($aImageCache[$sFileName]) && $aImageCache[$sFileName]) {
01459 $sCId = $aImageCache[$sFileName];
01460 } else {
01461 $sCId = $myUtilsObject->generateUID();
01462 $sMIME = $myUtils->oxMimeContentType($sFileName);
01463 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01464 if ($this->addEmbeddedImage($sFileName, $sCId, "image", "base64", $sMIME)) {
01465 $aImageCache[$sFileName] = $sCId;
01466 } else {
01467 $sCId = '';
01468 }
01469 }
01470 }
01471 if ($sCId && $sCId == $aImageCache[$sFileName]) {
01472 if ($sReplTag = str_replace($image, 'cid:' . $sCId, $aImage[0])) {
01473 $sBody = str_replace($aImage[0], $sReplTag, $sBody);
01474 $blReSetBody = true;
01475 }
01476 }
01477 }
01478 }
01479 }
01480
01481 if ($blReSetBody) {
01482 $this->setBody($sBody);
01483 }
01484 }
01485 }
01486
01492 public function setSubject($sSubject = null)
01493 {
01494
01495 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>'), $sSubject);
01496
01497 $this->set("Subject", $sSubject);
01498 }
01499
01505 public function getSubject()
01506 {
01507 return $this->Subject;
01508 }
01509
01517 public function setBody($sBody = null, $blClearSid = true)
01518 {
01519 if ($blClearSid) {
01520 $sBody = $this->_clearSidFromBody($sBody);
01521 }
01522
01523 $this->set("Body", $sBody);
01524 }
01525
01531 public function getBody()
01532 {
01533 return $this->Body;
01534 }
01535
01543 public function setAltBody($sAltBody = null, $blClearSid = true)
01544 {
01545 if ($blClearSid) {
01546 $sAltBody = $this->_clearSidFromBody($sAltBody);
01547 }
01548
01549
01550 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>'), $sAltBody);
01551
01552 $this->set("AltBody", $sAltBody);
01553 }
01554
01560 public function getAltBody()
01561 {
01562 return $this->AltBody;
01563 }
01564
01571 public function setRecipient($sAddress = null, $sName = null)
01572 {
01573 try {
01574 parent::AddAddress($sAddress, $sName);
01575
01576
01577 $this->_aRecipients[] = array($sAddress, $sName);
01578 } catch (Exception $oEx) {
01579 }
01580 }
01581
01589 public function getRecipient()
01590 {
01591 return $this->_aRecipients;
01592 }
01593
01597 public function clearAllRecipients()
01598 {
01599 $this->_aRecipients = array();
01600 parent::clearAllRecipients();
01601 }
01602
01612 public function setReplyTo($sEmail = null, $sName = null)
01613 {
01614 if (!oxRegistry::getUtils()->isValidEmail($sEmail)) {
01615 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01616 }
01617
01618 $this->_aReplies[] = array($sEmail, $sName);
01619
01620 try {
01621 parent::addReplyTo($sEmail, $sName);
01622 } catch (Exception $oEx) {
01623 }
01624 }
01625
01631 public function getReplyTo()
01632 {
01633 return $this->_aReplies;
01634 }
01635
01639 public function clearReplyTos()
01640 {
01641 $this->_aReplies = array();
01642 parent::clearReplyTos();
01643 }
01644
01651 public function setFrom($sFromAddress, $sFromName = null)
01652 {
01653
01654
01655
01656 $sFromAddress = substr($sFromAddress, 0, 150);
01657 $sFromName = substr($sFromName, 0, 150);
01658
01659 try {
01660 parent::setFrom($sFromAddress, $sFromName);
01661 } catch (Exception $oEx) {
01662 }
01663 }
01664
01670 public function getFrom()
01671 {
01672 return $this->From;
01673 }
01674
01680 public function getFromName()
01681 {
01682 return $this->FromName;
01683 }
01684
01691 public function setCharSet($sCharSet = null)
01692 {
01693 if ($sCharSet) {
01694 $this->_sCharSet = $sCharSet;
01695 } else {
01696 $this->_sCharSet = oxRegistry::getLang()->translateString("charset");
01697 }
01698 $this->set("CharSet", $this->_sCharSet);
01699 }
01700
01706 public function setMailer($sMailer = null)
01707 {
01708 $this->set("Mailer", $sMailer);
01709 }
01710
01716 public function getMailer()
01717 {
01718 return $this->Mailer;
01719 }
01720
01726 public function setHost($sHost = null)
01727 {
01728 $this->set("Host", $sHost);
01729 }
01730
01736 public function getErrorInfo()
01737 {
01738 return $this->ErrorInfo;
01739 }
01740
01747 public function setMailWordWrap($iWordWrap = null)
01748 {
01749 $this->set("WordWrap", $iWordWrap);
01750 }
01751
01757 public function setUseInlineImages($blUseImages = null)
01758 {
01759 $this->_blInlineImgEmail = $blUseImages;
01760 }
01761
01772 public function addAttachment($sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream')
01773 {
01774 $this->_aAttachments[] = array($sAttPath, $sAttFile, $sEncoding, $sType);
01775 $blResult = false;
01776
01777 try {
01778 $blResult = parent::addAttachment($sAttPath, $sAttFile, $sEncoding, $sType);
01779 } catch (Exception $oEx) {
01780 }
01781
01782 return $blResult;
01783 }
01784
01796 public function addEmbeddedImage($sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream')
01797 {
01798 $this->_aAttachments[] = array($sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid);
01799
01800 return parent::addEmbeddedImage($sFullPath, $sCid, $sAttFile, $sEncoding, $sType);
01801 }
01802
01808 public function getAttachments()
01809 {
01810 return $this->_aAttachments;
01811 }
01812
01818 public function clearAttachments()
01819 {
01820 $this->_aAttachments = array();
01821
01822 return parent::clearAttachments();
01823 }
01824
01834 public function headerLine($sName, $sValue)
01835 {
01836 if (stripos($sName, 'X-') !== false) {
01837 return;
01838 }
01839
01840 return parent::headerLine($sName, $sValue);
01841 }
01842
01848 protected function _getUseInlineImages()
01849 {
01850 return $this->_blInlineImgEmail;
01851 }
01852
01858 protected function _sendMailErrorMsg()
01859 {
01860
01861 $aRecipients = $this->getRecipient();
01862
01863 $sOwnerMessage = "Error sending eMail(" . $this->getSubject() . ") to: \n\n";
01864
01865 foreach ($aRecipients as $aEMail) {
01866 $sOwnerMessage .= $aEMail[0];
01867 $sOwnerMessage .= (!empty($aEMail[1])) ? ' (' . $aEMail[1] . ')' : '';
01868 $sOwnerMessage .= " \n ";
01869 }
01870 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01871
01872
01873 $oShop = $this->_getShop();
01874
01875 $blRet = @mail($oShop->oxshops__oxorderemail->value, "eMail problem in shop!", $sOwnerMessage);
01876
01877 return $blRet;
01878 }
01879
01889 protected function _addUserInfoOrderEMail($oOrder)
01890 {
01891 return $oOrder;
01892 }
01893
01903 protected function _addUserRegisterEmail($oUser)
01904 {
01905 return $oUser;
01906 }
01907
01917 protected function _addForgotPwdEmail($oShop)
01918 {
01919 return $oShop;
01920 }
01921
01931 protected function _addNewsletterDbOptInMail($oUser)
01932 {
01933 return $oUser;
01934 }
01935
01939 protected function _clearMailer()
01940 {
01941 $this->clearAllRecipients();
01942 $this->clearReplyTos();
01943 $this->clearAttachments();
01944
01945
01946 $this->error_count = 0;
01947 $this->ErrorInfo = '';
01948 }
01949
01955 protected function _setMailParams($oShop = null)
01956 {
01957 $this->_clearMailer();
01958
01959 if (!$oShop) {
01960 $oShop = $this->_getShop();
01961 }
01962
01963 $this->setFrom($oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue());
01964 $this->setSmtp($oShop);
01965 }
01966
01976 protected function _getShop($iLangId = null, $iShopId = null)
01977 {
01978 if ($iLangId === null && $iShopId === null) {
01979 if (isset($this->_oShop)) {
01980 return $this->_oShop;
01981 } else {
01982 return $this->_oShop = $this->getConfig()->getActiveShop();
01983 }
01984 }
01985
01986 $myConfig = $this->getConfig();
01987
01988 $oShop = oxNew('oxShop');
01989 if ($iShopId !== null) {
01990 $oShop->setShopId($iShopId);
01991 }
01992 if ($iLangId !== null) {
01993 $oShop->setLanguage($iLangId);
01994 }
01995 $oShop->load($myConfig->getShopId());
01996
01997 return $oShop;
01998 }
01999
02006 protected function _setSmtpAuthInfo($sUserName = null, $sUserPassword = null)
02007 {
02008 $this->set("SMTPAuth", true);
02009 $this->set("Username", $sUserName);
02010 $this->set("Password", $sUserPassword);
02011 }
02012
02018 protected function _setSmtpDebug($blDebug = null)
02019 {
02020 $this->set("SMTPDebug", $blDebug);
02021 }
02022
02026 protected function _setMailerPluginDir()
02027 {
02028 $this->set("PluginDir", getShopBasePath() . "core/phpmailer/");
02029 }
02030
02035 protected function _makeOutputProcessing()
02036 {
02037 $oOutput = oxNew("oxOutput");
02038 $this->setBody($oOutput->process($this->getBody(), "oxemail"));
02039 $this->setAltBody($oOutput->process($this->getAltBody(), "oxemail"));
02040 $oOutput->processEmail($this);
02041 }
02042
02048 protected function _sendMail()
02049 {
02050 $blResult = false;
02051 try {
02052 $blResult = parent::send();
02053 } catch (Exception $oException) {
02054 $oEx = oxNew("oxException");
02055 $oEx->setMessage($oException->getMessage());
02056 $oEx->debugOut();
02057 if ($this->getConfig()->getConfigParam('iDebug') != 0) {
02058 throw $oEx;
02059 }
02060 }
02061
02062 return $blResult;
02063 }
02064
02065
02069 protected function _processViewArray()
02070 {
02071 $oSmarty = $this->_getSmarty();
02072 $oOutputProcessor = oxNew("oxOutput");
02073
02074
02075 foreach ($this->_aViewData as $sKey => $sValue) {
02076 $oSmarty->assign($sKey, $sValue);
02077 }
02078
02079
02080 $aNewSmartyArray = $oOutputProcessor->processViewArray($oSmarty->get_template_vars(), "oxemail");
02081
02082 foreach ($aNewSmartyArray as $key => $val) {
02083 $oSmarty->assign($key, $val);
02084 }
02085 }
02086
02092 public function getCharset()
02093 {
02094 if (!$this->_sCharSet) {
02095 return oxRegistry::getLang()->translateString("charset");
02096 } else {
02097 return $this->CharSet;
02098 }
02099 }
02100
02106 public function getShop()
02107 {
02108 return $this->_getShop();
02109 }
02110
02116 public function setShop($oShop)
02117 {
02118 $this->_oShop = $oShop;
02119 }
02120
02126 public function getViewConfig()
02127 {
02128 return $this->getConfig()->getActiveView()->getViewConfig();
02129 }
02130
02136 public function getView()
02137 {
02138 return $this->getConfig()->getActiveView();
02139 }
02140
02146 public function getCurrency()
02147 {
02148 $oConfig = oxRegistry::getConfig();
02149
02150 return $oConfig->getActShopCurrencyObject();
02151 }
02152
02159 public function setViewData($sKey, $sValue)
02160 {
02161 $this->_aViewData[$sKey] = $sValue;
02162 }
02163
02169 public function getViewData()
02170 {
02171 return $this->_aViewData;
02172 }
02173
02181 public function getViewDataItem($sKey)
02182 {
02183 if (isset($this->_aViewData[$sKey])) {
02184 return $this->_aViewData;
02185 }
02186 }
02187
02193 public function setUser($oUser)
02194 {
02195 $this->_aViewData["oUser"] = $oUser;
02196 }
02197
02203 public function getUser()
02204 {
02205 return $this->_aViewData["oUser"];
02206 }
02207
02215 public function getOrderFileList($sOrderId)
02216 {
02217 $oOrderList = oxNew('oxOrderFileList');
02218 $oOrderList->loadOrderFiles($sOrderId);
02219
02220 if (count($oOrderList) > 0) {
02221 return $oOrderList;
02222 }
02223
02224 return false;
02225 }
02226
02234 private function _clearSidFromBody($sAltBody)
02235 {
02236 return oxStr::getStr()->preg_replace('/(\?|&(amp;)?)(force_)?(admin_)?sid=[A-Z0-9\.]+/i', '\1shp=' . $this->getConfig()->getShopId(), $sAltBody);
02237 }
02238 }