deliveryset_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',     'oxobject2delivery', 0, 0, 1 ),
00012                                         )
00013                     );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024     protected function _getQuery()
00025     {
00026         $oDb = oxDb::getDb();
00027         $sId = oxConfig::getParameter( 'oxid' );
00028         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00029 
00030         $sgroupTable = $this->_getViewName('oxgroups');
00031 
00032         // category selected or not ?
00033         if ( !$sId) {
00034             $sQAdd  = " from $sgroupTable where 1 ";
00035         } else {
00036             $sQAdd  = " from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId );
00037             $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ";
00038         }
00039 
00040         if ( $sSynchId && $sSynchId != $sId ) {
00041             $sQAdd .= " and $sgroupTable.oxid not in ( select $sgroupTable.oxid from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId );
00042             $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ) ";
00043         }
00044 
00045         return $sQAdd;
00046     }
00047 
00053     public function removegroupfromset()
00054     {
00055         $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
00056         if ( oxConfig::getParameter( 'all' ) ) {
00057 
00058             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00059             oxDb::getDb()->Execute( $sQ );
00060 
00061         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00062             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00063             oxDb::getDb()->Execute( $sQ );
00064         }
00065     }
00066 
00072     public function addgrouptoset()
00073     {
00074         $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00075         $soxId      = oxConfig::getParameter( 'synchoxid' );
00076 
00077         // adding
00078         if ( oxConfig::getParameter( 'all' ) ) {
00079             $sGroupTable = $this->_getViewName('oxgroups');
00080             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00081         }
00082         if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00083             foreach ( $aChosenCat as $sChosenCat) {
00084                 $oObject2Delivery = oxNew( 'oxbase' );
00085                 $oObject2Delivery->init( 'oxobject2delivery' );
00086                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00087                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCat);
00088                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxdelsetg");
00089                 $oObject2Delivery->save();
00090             }
00091         }
00092     }
00093 }