33 $oNewsletter =
oxNew(
"oxNewsLetter");
35 $oNewsletterGroups = $oNewsletter->getGroups();
39 $sQGroups =
" ( oxobject2group.oxgroupsid in ( ";
41 foreach ($oNewsletterGroups as $sInGroup) {
42 $sSearchKey = $sInGroup->oxgroups__oxid->value;
46 $sQGroups .= $oDB->quote($sSearchKey);
53 $sQGroups =
" oxobject2group.oxobjectid is null ";
59 $iMaxCnt = (int)
$myConfig->getConfigParam(
'iCntofMails');
62 $sQ =
"select oxnewssubscribed.oxuserid, oxnewssubscribed.oxemail, oxnewssubscribed.oxsal,
63 oxnewssubscribed.oxfname, oxnewssubscribed.oxlname, oxnewssubscribed.oxemailfailed
64 from oxnewssubscribed left join oxobject2group on
65 oxobject2group.oxobjectid = oxnewssubscribed.oxuserid where
66 ( oxobject2group.oxshopid = '{$sShopId}' or oxobject2group.oxshopid is null ) and
67 $sQGroups and oxnewssubscribed.oxdboptin = 1 and oxnewssubscribed.oxshopid = '{$sShopId}'
68 group by oxnewssubscribed.oxemail";
70 $oRs = $oDB->selectLimit($sQ, 100, $iStart);
71 $blContinue = ($oRs !=
false && $oRs->recordCount() > 0);
74 $blLoadAction =
$myConfig->getConfigParam(
'bl_perfLoadAktion');
75 while (!$oRs->EOF && $iSendCnt < $iMaxCnt) {
77 if ($oRs->fields[
'oxemailfailed'] !=
"1") {
78 $sUserId = $oRs->fields[
'oxuserid'];
82 if (!$oDB->getOne(
"select oxid from oxuser where oxid = " . $oDB->quote($sUserId),
false,
false)) {
87 if (!isset($sUserId) || !$sUserId) {
89 $oUser =
oxNew(
"oxuser");
90 $oUser->oxuser__oxusername =
new oxField($oRs->fields[
'oxemail']);
91 $oUser->oxuser__oxsal =
new oxField($oRs->fields[
'oxsal']);
92 $oUser->oxuser__oxfname =
new oxField($oRs->fields[
'oxfname']);
93 $oUser->oxuser__oxlname =
new oxField($oRs->fields[
'oxlname']);
94 $oNewsletter->prepare($oUser, $blLoadAction);
96 $oNewsletter->prepare($sUserId, $blLoadAction);
99 if ($oNewsletter->send($iSendCnt)) {
101 $oRemark =
oxNew(
"oxremark");
102 $oRemark->oxremark__oxtext =
new oxField($oNewsletter->getPlainText());
103 $oRemark->oxremark__oxparentid =
new oxField($sUserId);
104 $oRemark->oxremark__oxshopid =
new oxField($sShopId);
105 $oRemark->oxremark__oxtype =
new oxField(
"n");
108 $this->_aMailErrors[] =
"problem sending to : " . $oRs->fields[
'oxemail'];
117 $iSend = $iSendCnt + (ceil($iStart / $iMaxCnt) - 1) * $iMaxCnt;
118 $iSend = $iSend > $iUserCount ? $iUserCount : $iSend;
120 $this->_aViewData[
"iStart"] = $iStart;
121 $this->_aViewData[
"iSend"] = $iSend;
125 return "newsletter_send.tpl";
129 return "newsletter_done.tpl";
141 if ($iCnt === null) {
155 $this->_iUserCount = null;
175 $sNode =
'newsletter_list';
183 $this->_aViewData[
'editnavi'] = $myAdminNavig->getTabs($sNode, $iActTab);
186 $this->_aViewData[
'actlocation'] = $myAdminNavig->getActiveTab($sNode, $iActTab);
189 $this->_aViewData[
'default_edit'] = $myAdminNavig->getActiveTab($sNode, $this->_iDefEdit);
192 $this->_aViewData[
'actedit'] = $iActTab;