Go to the documentation of this file.00001 <?php
00002
00008 class Newsletter_Selection extends oxAdminDetails
00009 {
00017 public function render()
00018 {
00019 parent::render();
00020
00021
00022 $oGroups = oxNew( "oxlist" );
00023 $oGroups->init( "oxgroups" );
00024 $oGroups->selectString( "select * from ".getViewName( "oxgroups", $this->_iEditLang ) );
00025
00026
00027 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00028 if ( $soxId != "-1" && isset( $soxId)) {
00029
00030 $oNewsletter = oxNew( "oxnewsletter" );
00031 $oNewsletter->load( $soxId );
00032 $oNewsletterGroups = $oNewsletter->getGroups();
00033 $this->_aViewData["edit"] = $oNewsletter;
00034
00035
00036 foreach ( $oNewsletterGroups as $oInGroup ) {
00037 foreach ( $oGroups as $sKey => $oGroup ) {
00038 if ( $oGroup->oxgroups__oxid->value == $oInGroup->oxgroups__oxid->value ) {
00039
00040 $oGroups->offsetUnset( $sKey );
00041 break;
00042 }
00043 }
00044 }
00045
00046
00047
00048 $oDB = oxDb::getDb();
00049 $sSelectGroups = " ( oxobject2group.oxgroupsid in ( ";
00050 $blSep = false;
00051 foreach ( $oNewsletterGroups as $sInGroup) {
00052 $sSearchKey = $sInGroup->oxgroups__oxid->value;
00053 if ( $blSep)
00054 $sSelectGroups .= ",";
00055 $sSelectGroups .= $oDB->quote( $sSearchKey );
00056 $blSep = true;
00057 }
00058 $sSelectGroups .= ") ) ";
00059
00060 if ( !$blSep)
00061 $sSelectGroups = " oxobject2group.oxobjectid is null ";
00062
00063 $sSelect = "select oxnewssubscribed.oxemail from oxnewssubscribed left join oxobject2group on oxobject2group.oxobjectid = oxnewssubscribed.oxuserid where ( oxobject2group.oxshopid = '".$this->getConfig()->getShopID()."' or oxobject2group.oxshopid is null ) and $sSelectGroups and oxnewssubscribed.oxdboptin = 1 and (not (oxnewssubscribed.oxemailfailed = '1')) and (not(oxnewssubscribed.oxemailfailed = \"1\")) group by oxnewssubscribed.oxemail";
00064
00065 $rs = $oDB->execute( $sSelect);
00066 $iCnt = 0;
00067 if ($rs != false && $rs->recordCount() > 0) {
00068 while (!$rs->EOF) {
00069 $iCnt++;
00070 $rs->moveNext();
00071 }
00072 }
00073 $this->_aViewData["user"] = $iCnt;
00074
00075
00076 if ( oxConfig::getParameter("aoc") ) {
00077
00078 $aColumns = array();
00079 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00080 $this->_aViewData['oxajax'] = $aColumns;
00081
00082 return "popups/newsletter_selection.tpl";
00083 }
00084 }
00085
00086 $this->_aViewData["allgroups"] = $oGroups;
00087
00088 return "newsletter_selection.tpl";
00089 }
00090
00096 public function save()
00097 {
00098 $soxId = $this->getEditObjectId();
00099 $aParams = oxConfig::getParameter( "editval");
00100
00101
00102 $sShopID = oxSession::getVar( "actshop");
00103 $aParams['oxnewsletter__oxshopid'] = $sShopID;
00104
00105 $oNewsletter = oxNew( "oxNewsLetter" );
00106 if( $soxId != "-1")
00107 $oNewsletter->load( $soxId );
00108 else
00109 $aParams['oxnewsletter__oxid'] = null;
00110
00111 $oNewsletter->assign( $aParams );
00112 $oNewsletter->save();
00113
00114
00115 $this->setEditObjectId( $oNewsletter->getId() );
00116 }
00117 }