Go to the documentation of this file.00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
00004 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00005 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00006 array( 'oxid', 'oxgroups', 0, 0, 1 ),
00007 ),
00008 'container2' => array(
00009 array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00010 array( 'oxid', 'oxgroups', 0, 0, 0 ),
00011 array( 'oxid', 'oxobject2group', 0, 0, 1 ),
00012 )
00013 );
00014
00018 class ajaxComponent extends ajaxListComponent
00019 {
00025 protected function _getQuery()
00026 {
00027
00028 $sGroupTable = $this->_getViewName('oxgroups');
00029 $oDb = oxDb::getDb();
00030 $sDiscountId = oxConfig::getParameter( 'oxid' );
00031 $sSynchDiscountId = oxConfig::getParameter( 'synchoxid' );
00032
00033
00034 if ( !$sDiscountId ) {
00035 $sQAdd = " from $sGroupTable where 1 ";
00036 } else {
00037 $sQAdd = " from oxobject2group left join $sGroupTable on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00038 $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sDiscountId );
00039 }
00040
00041 if ( $sSynchDiscountId && $sSynchDiscountId != $sDiscountId ) {
00042 $sQAdd .= " and $sGroupTable.oxid not in ( ";
00043 $sQAdd .= " select $sGroupTable.oxid from oxobject2group left join $sGroupTable on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00044 $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sSynchDiscountId )." ) ";
00045 }
00046
00047
00048 return $sQAdd;
00049 }
00050
00056 public function removegroupfromnewsletter()
00057 {
00058 $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00059 if ( oxConfig::getParameter( 'all' ) ) {
00060
00061 $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00062 oxDb::getDb()->Execute( $sQ );
00063
00064 } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00065 $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00066 oxDb::getDb()->Execute( $sQ );
00067 }
00068 }
00069
00075 public function addgrouptonewsletter()
00076 {
00077 $aAddGroups = $this->_getActionIds( 'oxgroups.oxid' );
00078 $soxId = oxConfig::getParameter( 'synchoxid' );
00079
00080 if ( oxConfig::getParameter( 'all' ) ) {
00081 $sGroupTable = $this->_getViewName('oxgroups');
00082 $aAddGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00083 }
00084 if ( $soxId && $soxId != "-1" && is_array( $aAddGroups ) ) {
00085 foreach ($aAddGroups as $sAddgroup) {
00086 $oNewGroup = oxNew( "oxobject2group" );
00087 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00088 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00089 $oNewGroup->save();
00090 }
00091 }
00092 }
00093 }