news_main.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
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                     );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024     protected function _getQuery()
00025     {
00026         // active AJAX component
00027         $sGroupTable = $this->_getViewName('oxgroups');
00028         $oDb = oxDb::getDb();
00029         $sDiscountId      = oxConfig::getParameter( 'oxid' );
00030         $sSynchDiscountId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         // category selected or not ?
00033         if ( !$sDiscountId) {
00034             $sQAdd  = " from $sGroupTable where 1 ";
00035         } else {
00036             $sQAdd  = " from oxobject2group left join $sGroupTable on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00037             $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sDiscountId );
00038         }
00039 
00040         if ( $sSynchDiscountId && $sSynchDiscountId != $sDiscountId) {
00041             $sQAdd .= ' and '.$sGroupTable.'.oxid not in ( select '.$sGroupTable.'.oxid from oxobject2group left join '.$sGroupTable.' on oxobject2group.oxgroupsid='.$sGroupTable.'.oxid ';
00042             $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sSynchDiscountId )." ) ";
00043         }
00044 
00045         return $sQAdd;
00046     }
00047 
00053     public function removegroupfromnews()
00054     {
00055         $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00056         if ( oxConfig::getParameter( 'all' ) ) {
00057 
00058             $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00059             oxDb::getDb()->Execute( $sQ );
00060 
00061         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00062             $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00063             oxDb::getDb()->Execute( $sQ );
00064         }
00065     }
00066 
00072     public function addgrouptonews()
00073     {
00074         $aAddGroups = $this->_getActionIds( 'oxgroups.oxid' );
00075         $soxId      = oxConfig::getParameter( 'synchoxid' );
00076 
00077         if ( oxConfig::getParameter( 'all' ) ) {
00078             $sGroupTable = $this->_getViewName('oxgroups');
00079             $aAddGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00080         }
00081         if ( $soxId && $soxId != "-1" && is_array( $aAddGroups ) ) {
00082             foreach ($aAddGroups as $sAddgroup) {
00083                 $oNewGroup = oxNew( "oxobject2group" );
00084                 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00085                 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00086                 $oNewGroup->save();
00087             }
00088         }
00089     }
00090 }