OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
actions_groups_ajax.php
Go to the documentation of this file.
1 <?php
2 
7 {
13  protected $_aColumns = array( 'container1' => array( // field , table, visible, multilanguage, ident
14  array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
15  array( 'oxid', 'oxgroups', 0, 0, 0 ),
16  array( 'oxid', 'oxgroups', 0, 0, 1 ),
17  ),
18  'container2' => array(
19  array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
20  array( 'oxid', 'oxgroups', 0, 0, 0 ),
21  array( 'oxid', 'oxobject2action', 0, 0, 1 ),
22  )
23  );
24 
30  protected function _getQuery()
31  {
32  // active AJAX component
33  $sGroupTable = $this->_getViewName( 'oxgroups' );
34  $oDb = oxDb::getDb();
35 
36  $sId = oxConfig::getParameter( 'oxid' );
37  $sSynchId = oxConfig::getParameter( 'synchoxid' );
38 
39  // category selected or not ?
40  if ( !$sId ) {
41  $sQAdd = " from $sGroupTable where 1 ";
42  } else {
43  $sQAdd .= " from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid ";
44  $sQAdd .= " and oxobject2action.oxactionid = ".$oDb->quote( $sId )." and oxobject2action.oxclass = 'oxgroups' ";
45  }
46 
47  if ( $sSynchId && $sSynchId != $sId) {
48  $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid ";
49  $sQAdd .= " and oxobject2action.oxactionid = ".$oDb->quote( $sSynchId )." and oxobject2action.oxclass = 'oxgroups' ) ";
50  }
51 
52  return $sQAdd;
53  }
54 
60  public function removePromotionGroup()
61  {
62  $aRemoveGroups = $this->_getActionIds( 'oxobject2action.oxid' );
63  if ( oxConfig::getParameter( 'all' ) ) {
64  $sQ = $this->_addFilter( "delete oxobject2action.* ".$this->_getQuery() );
65  oxDb::getDb()->Execute( $sQ );
66  } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
67  $sQ = "delete from oxobject2action where oxobject2action.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
68  oxDb::getDb()->Execute( $sQ );
69  }
70  }
71 
77  public function addPromotionGroup()
78  {
79  $aChosenGroup = $this->_getActionIds( 'oxgroups.oxid' );
80  $soxId = oxConfig::getParameter( 'synchoxid' );
81 
82  if ( oxConfig::getParameter( 'all' ) ) {
83  $sGroupTable = $this->_getViewName('oxgroups');
84  $aChosenGroup = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
85  }
86  if ( $soxId && $soxId != "-1" && is_array( $aChosenGroup ) ) {
87  foreach ( $aChosenGroup as $sChosenGroup) {
88  $oObject2Promotion = oxNew( "oxbase" );
89  $oObject2Promotion->init( 'oxobject2action' );
90  $oObject2Promotion->oxobject2action__oxactionid = new oxField( $soxId );
91  $oObject2Promotion->oxobject2action__oxobjectid = new oxField( $sChosenGroup );
92  $oObject2Promotion->oxobject2action__oxclass = new oxField( "oxgroups" );
93  $oObject2Promotion->save();
94  }
95  }
96  }
97 }