Go to the documentation of this file.00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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', 'oxobject2discount', 0, 0, 1 ),
00012 array( 'oxid', 'oxcategories', 0, 0, 1 )
00013 ),
00014 );
00018 class ajaxComponent extends ajaxListComponent
00019 {
00025 protected function _getQuery()
00026 {
00027 $oDb = oxDb::getDb();
00028 $sId = oxConfig::getParameter( 'oxid' );
00029 $sSynchId = oxConfig::getParameter( 'synchoxid' );
00030
00031 $sCategoryTable = $this->_getViewName('oxcategories');
00032
00033
00034 if ( !$sId) {
00035 $sQAdd = " from $sCategoryTable";
00036 } else {
00037 $sQAdd = " from oxobject2discount, $sCategoryTable where $sCategoryTable.oxid=oxobject2discount.oxobjectid ";
00038 $sQAdd .= " and oxobject2discount.oxdiscountid = ".$oDb->quote( $sId )." and oxobject2discount.oxtype = 'oxcategories' ";
00039 }
00040
00041 if ( $sSynchId && $sSynchId != $sId) {
00042
00043 $sSubSelect = " select $sCategoryTable.oxid from oxobject2discount, $sCategoryTable where $sCategoryTable.oxid=oxobject2discount.oxobjectid ";
00044 $sSubSelect .= " and oxobject2discount.oxdiscountid = ".$oDb->quote( $sSynchId )." and oxobject2discount.oxtype = 'oxcategories' ";
00045 if ( stristr( $sQAdd, 'where' ) === false )
00046 $sQAdd .= ' where ';
00047 else
00048 $sQAdd .= ' and ';
00049 $sQAdd .= " $sCategoryTable.oxid not in ( $sSubSelect ) ";
00050 }
00051
00052 return $sQAdd;
00053 }
00054
00060 public function removedisccat()
00061 {
00062 $aChosenCat = $this->_getActionIds( 'oxobject2discount.oxid' );
00063 if ( oxConfig::getParameter( 'all' ) ) {
00064
00065 $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00066 oxDb::getDb()->Execute( $sQ );
00067
00068 } elseif ( is_array( $aChosenCat ) ) {
00069 $sQ = "delete from oxobject2discount where oxobject2discount.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCat ) ) . ") ";
00070 oxDb::getDb()->Execute( $sQ );
00071 }
00072 }
00073
00079 public function adddisccat()
00080 {
00081 $aChosenCat = $this->_getActionIds( 'oxcategories.oxid' );
00082 $soxId = oxConfig::getParameter( 'synchoxid');
00083
00084 if ( oxConfig::getParameter( 'all' ) ) {
00085 $sCategoryTable = $this->_getViewName('oxcategories');
00086 $aChosenCat = $this->_getAll( $this->_addFilter( "select $sCategoryTable.oxid ".$this->_getQuery() ) );
00087 }
00088 if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00089 foreach ( $aChosenCat as $sChosenCat) {
00090 $oObject2Discount = oxNew( "oxbase" );
00091 $oObject2Discount->init( 'oxobject2discount' );
00092 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00093 $oObject2Discount->oxobject2discount__oxobjectid = new oxField($sChosenCat);
00094 $oObject2Discount->oxobject2discount__oxtype = new oxField("oxcategories");
00095 $oObject2Discount->save();
00096 }
00097 }
00098 }
00099 }