delivery_categories.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', 'oxcategories', 1, 1, 0 ),
00005                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00006                                         array( 'oxid',    'oxcategories', 0, 0, 1 )
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle', 'oxcategories', 1, 1, 0 ),
00010                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00011                                         array( 'oxid',    'oxobject2delivery', 0, 0, 1 ),
00012                                         array( 'oxid',    'oxcategories',      0, 0, 1 )
00013                                         ),
00014                    );
00018 class ajaxComponent extends ajaxListComponent
00019 {
00025     protected function _getQuery()
00026     {
00027         // looking for table/view
00028         $sCatTable = getViewName('oxcategories');
00029 
00030         $sDelId      = oxConfig::getParameter( 'oxid' );
00031         $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00032 
00033         // category selected or not ?
00034         if ( !$sDelId) {
00035             $sQAdd  = " from $sCatTable ";
00036         } else {
00037             $sQAdd  = " from oxobject2delivery left join $sCatTable on $sCatTable.oxid=oxobject2delivery.oxobjectid ";
00038             $sQAdd .= " where oxobject2delivery.oxdeliveryid = '$sDelId' and oxobject2delivery.oxtype = 'oxcategories' ";
00039         }
00040 
00041         if ( $sSynchDelId && $sSynchDelId != $sDelId) {
00042             // dodger performance
00043             $sSubSelect  = " select $sCatTable.oxid from oxobject2delivery left join $sCatTable on $sCatTable.oxid=oxobject2delivery.oxobjectid ";
00044             $sSubSelect .= " where oxobject2delivery.oxdeliveryid = '$sSynchDelId' and oxobject2delivery.oxtype = 'oxcategories' ";
00045             if ( stristr( $sQAdd, 'where' ) === false )
00046                 $sQAdd .= ' where ';
00047             else
00048                 $sQAdd .= ' and ';
00049             $sQAdd .= " $sCatTable.oxid not in ( $sSubSelect ) ";
00050         }
00051 
00052         return $sQAdd;
00053     }
00054 
00060     public function removecatfromdel()
00061     {
00062         $aChosenCat = $this->_getActionIds( 'oxobject2delivery.oxid' );
00063 
00064         // removing all
00065         if ( oxConfig::getParameter( 'all' ) ) {
00066 
00067             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00068             oxDb::getDb()->Execute( $sQ );
00069 
00070         } elseif ( is_array( $aChosenCat ) ) {
00071             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in ('" . implode( "', '", $aChosenCat ) . "') ";
00072             oxDb::getDb()->Execute( $sQ );
00073         }
00074     }
00075 
00081     public function addcattodel()
00082     {
00083         $aChosenCat = $this->_getActionIds( 'oxcategories.oxid' );
00084         $soxId      = oxConfig::getParameter( 'synchoxid');
00085 
00086         // adding
00087         if ( oxConfig::getParameter( 'all' ) ) {
00088             $sCatTable = getViewName('oxcategories');
00089             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sCatTable.oxid ".$this->_getQuery() ) );
00090         }
00091 
00092         if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenCat) && $aChosenCat) {
00093             foreach ( $aChosenCat as $sChosenCat) {
00094                 $oObject2Delivery = oxNew( 'oxbase' );
00095                 $oObject2Delivery->init( 'oxobject2delivery' );
00096                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00097                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenCat);
00098                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxcategories");
00099                 $oObject2Delivery->save();
00100             }
00101         }
00102     }
00103 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5