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