32 $oNewsletter =
oxNew(
"oxNewsLetter" );
34 $oNewsletterGroups = $oNewsletter->getGroups();
38 $sQGroups =
" ( oxobject2group.oxgroupsid in ( ";
40 foreach ( $oNewsletterGroups as $sInGroup ) {
41 $sSearchKey = $sInGroup->oxgroups__oxid->value;
45 $sQGroups .= $oDB->quote( $sSearchKey );
52 $sQGroups =
" oxobject2group.oxobjectid is null ";
58 $iMaxCnt = (int)
$myConfig->getConfigParam(
'iCntofMails' );
61 $sQ =
"select oxnewssubscribed.oxuserid, oxnewssubscribed.oxemail, oxnewssubscribed.oxsal,
62 oxnewssubscribed.oxfname, oxnewssubscribed.oxlname, oxnewssubscribed.oxemailfailed
63 from oxnewssubscribed left join oxobject2group on
64 oxobject2group.oxobjectid = oxnewssubscribed.oxuserid where
65 ( oxobject2group.oxshopid = '{$sShopId}' or oxobject2group.oxshopid is null ) and
66 $sQGroups and oxnewssubscribed.oxdboptin = 1 and oxnewssubscribed.oxshopid = '{$sShopId}'
67 group by oxnewssubscribed.oxemail";
69 $oRs = $oDB->selectLimit( $sQ, 100, $iStart );
70 $blContinue = ( $oRs !=
false && $oRs->recordCount() > 0 );
73 $blLoadAction =
$myConfig->getConfigParam(
'bl_perfLoadAktion' );
74 while ( !$oRs->EOF && $iSendCnt < $iMaxCnt ) {
76 if ( $oRs->fields[
'oxemailfailed'] !=
"1" ) {
77 $sUserId = $oRs->fields[
'oxuserid'];
81 if ( !$oDB->getOne(
"select oxid from oxuser where oxid = ".$oDB->quote( $sUserId ),
false, false ) ) {
86 if ( !isset( $sUserId ) || !$sUserId ) {
88 $oUser =
oxNew(
"oxuser" );
89 $oUser->oxuser__oxusername =
new oxField( $oRs->fields[
'oxemail'] );
90 $oUser->oxuser__oxsal =
new oxField( $oRs->fields[
'oxsal'] );
91 $oUser->oxuser__oxfname =
new oxField( $oRs->fields[
'oxfname'] );
92 $oUser->oxuser__oxlname =
new oxField( $oRs->fields[
'oxlname'] );
93 $oNewsletter->prepare( $oUser, $blLoadAction );
95 $oNewsletter->prepare( $sUserId, $blLoadAction );
98 if ( $oNewsletter->send( $iSendCnt ) ) {
100 $oRemark =
oxNew(
"oxremark" );
101 $oRemark->oxremark__oxtext =
new oxField( $oNewsletter->getPlainText() );
102 $oRemark->oxremark__oxparentid =
new oxField( $sUserId );
103 $oRemark->oxremark__oxshopid =
new oxField( $sShopId );
104 $oRemark->oxremark__oxtype =
new oxField(
"n" );
107 $this->_aMailErrors[] =
"problem sending to : ".$oRs->fields[
'oxemail'];
116 $iSend = $iSendCnt + ( ceil( $iStart / $iMaxCnt ) - 1 ) * $iMaxCnt;
117 $iSend = $iSend > $iUserCount ? $iUserCount : $iSend;
119 $this->_aViewData[
"iStart"] = $iStart;
120 $this->_aViewData[
"iSend"] = $iSend;
124 return "newsletter_send.tpl";
127 return "newsletter_done.tpl";
139 if ( $iCnt === null ) {
154 $this->_iUserCount = null;
176 $sNode =
'newsletter_list';
184 $this->_aViewData[
'editnavi'] = $myAdminNavig->getTabs( $sNode, $iActTab );
187 $this->_aViewData[
'actlocation'] = $myAdminNavig->getActiveTab( $sNode, $iActTab );
190 $this->_aViewData[
'default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
193 $this->_aViewData[
'actedit'] = $iActTab;