actions_groups.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',     'oxobject2action', 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 
00030         $sId      = oxConfig::getParameter( 'oxid' );
00031         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00032 
00033         // category selected or not ?
00034         if ( !$sId ) {
00035             $sQAdd  = " from $sGroupTable where 1 ";
00036         } else {
00037             $sQAdd .= " from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid ";
00038             $sQAdd .= " and oxobject2action.oxactionid = ".$oDb->quote( $sId )." and oxobject2action.oxclass = 'oxgroups' ";
00039         }
00040 
00041         if ( $sSynchId && $sSynchId != $sId) {
00042             $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid ";
00043             $sQAdd .= " and oxobject2action.oxactionid = ".$oDb->quote( $sSynchId )." and oxobject2action.oxclass = 'oxgroups' ) ";
00044         }
00045 
00046         return $sQAdd;
00047     }
00048 
00054     public function removePromotionGroup()
00055     {
00056         $aRemoveGroups = $this->_getActionIds( 'oxobject2action.oxid' );
00057         if ( oxConfig::getParameter( 'all' ) ) {
00058             $sQ = $this->_addFilter( "delete oxobject2action.* ".$this->_getQuery() );
00059             oxDb::getDb()->Execute( $sQ );
00060         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00061             $sQ = "delete from oxobject2action where oxobject2action.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00062             oxDb::getDb()->Execute( $sQ );
00063         }
00064     }
00065 
00071     public function addPromotionGroup()
00072     {
00073         $aChosenGroup = $this->_getActionIds( 'oxgroups.oxid' );
00074         $soxId        = oxConfig::getParameter( 'synchoxid' );
00075 
00076         if ( oxConfig::getParameter( 'all' ) ) {
00077             $sGroupTable  = $this->_getViewName('oxgroups');
00078             $aChosenGroup = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00079         }
00080         if ( $soxId && $soxId != "-1" && is_array( $aChosenGroup ) ) {
00081             foreach ( $aChosenGroup as $sChosenGroup) {
00082                 $oObject2Promotion = oxNew( "oxbase" );
00083                 $oObject2Promotion->init( 'oxobject2action' );
00084                 $oObject2Promotion->oxobject2action__oxactionid = new oxField( $soxId );
00085                 $oObject2Promotion->oxobject2action__oxobjectid = new oxField( $sChosenGroup );
00086                 $oObject2Promotion->oxobject2action__oxclass    = new oxField( "oxgroups" );
00087                 $oObject2Promotion->save();
00088             }
00089         }
00090     }
00091 }