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