deliveryset_groups_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class deliveryset_groups_ajax extends ajaxListComponent
00007 {
00013     protected $_aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00014                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00015                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00016                                         array( 'oxid',     'oxgroups', 0, 0, 1 ),
00017                                         ),
00018                                     'container2' => array(
00019                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00020                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00021                                         array( 'oxid',     'oxobject2delivery', 0, 0, 1 ),
00022                                         )
00023                                 );
00024 
00030     protected function _getQuery()
00031     {
00032         $oDb = oxDb::getDb();
00033         $sId = $this->getConfig()->getRequestParameter( 'oxid' );
00034         $sSynchId = $this->getConfig()->getRequestParameter( 'synchoxid' );
00035 
00036         $sgroupTable = $this->_getViewName('oxgroups');
00037 
00038         // category selected or not ?
00039         if ( !$sId) {
00040             $sQAdd  = " from $sgroupTable where 1 ";
00041         } else {
00042             $sQAdd  = " from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sId );
00043             $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ";
00044         }
00045 
00046         if ( $sSynchId && $sSynchId != $sId ) {
00047             $sQAdd .= " and $sgroupTable.oxid not in ( select $sgroupTable.oxid from oxobject2delivery, $sgroupTable where oxobject2delivery.oxdeliveryid = ".$oDb->quote( $sSynchId );
00048             $sQAdd .= " and oxobject2delivery.oxobjectid = $sgroupTable.oxid and oxobject2delivery.oxtype = 'oxdelsetg' ) ";
00049         }
00050 
00051         return $sQAdd;
00052     }
00053 
00059     public function removeGroupFromSet()
00060     {
00061         $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
00062         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00063 
00064             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00065             oxDb::getDb()->Execute( $sQ );
00066 
00067         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00068             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00069             oxDb::getDb()->Execute( $sQ );
00070         }
00071     }
00072 
00078     public function addGroupToSet()
00079     {
00080         $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00081         $soxId      = $this->getConfig()->getRequestParameter( 'synchoxid' );
00082 
00083         // adding
00084         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00085             $sGroupTable = $this->_getViewName('oxgroups');
00086             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00087         }
00088         if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00089             foreach ( $aChosenCat as $sChosenCat) {
00090                 $oObject2Delivery = oxNew( 'oxbase' );
00091                 $oObject2Delivery->init( 'oxobject2delivery' );
00092                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00093                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCat);
00094                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxdelsetg");
00095                 $oObject2Delivery->save();
00096             }
00097         }
00098     }
00099 }