OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
payment_main_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', 'oxobject2group', 0, 0, 1),
23  )
24  );
25 
31  protected function _getQuery()
32  {
33  // looking for table/view
34  $sGroupTable = $this->_getViewName('oxgroups');
35  $sGroupId = $this->getConfig()->getRequestParameter('oxid');
36  $sSynchGroupId = $this->getConfig()->getRequestParameter('synchoxid');
37  $oDb = oxDb::getDb();
38 
39  // category selected or not ?
40  if (!$sGroupId) {
41  $sQAdd = " from {$sGroupTable} ";
42  } else {
43  $sQAdd = " from {$sGroupTable}, oxobject2group where ";
44  $sQAdd .= " oxobject2group.oxobjectid = " . $oDb->quote($sGroupId) .
45  " and oxobject2group.oxgroupsid = {$sGroupTable}.oxid ";
46  }
47 
48  if (!$sSynchGroupId) {
49  $sSynchGroupId = $this->getConfig()->getRequestParameter('oxajax_synchfid');
50  }
51  if ($sSynchGroupId && $sSynchGroupId != $sGroupId) {
52  if (!$sGroupId) {
53  $sQAdd .= 'where ';
54  } else {
55  $sQAdd .= 'and ';
56  }
57  $sQAdd .= " {$sGroupTable}.oxid not in ( select {$sGroupTable}.oxid from {$sGroupTable}, oxobject2group " .
58  "where oxobject2group.oxobjectid = " . $oDb->quote($sSynchGroupId) .
59  " and oxobject2group.oxgroupsid = $sGroupTable.oxid ) ";
60  }
61 
62  return $sQAdd;
63  }
64 
68  public function removePayGroup()
69  {
70  $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
71  if ($this->getConfig()->getRequestParameter('all')) {
72 
73  $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
74  oxDb::getDb()->Execute($sQ);
75 
76  } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
77  $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
78  $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . $sRemoveGroups . ") ";
79  oxDb::getDb()->Execute($sQ);
80  }
81  }
82 
86  public function addPayGroup()
87  {
88  $aAddGroups = $this->_getActionIds('oxgroups.oxid');
89  $soxId = $this->getConfig()->getRequestParameter('synchoxid');
90 
91  if ($this->getConfig()->getRequestParameter('all')) {
92  $sGroupTable = $this->_getViewName('oxgroups');
93  $aAddGroups = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
94  }
95  if ($soxId && $soxId != "-1" && is_array($aAddGroups)) {
96  foreach ($aAddGroups as $sAddgroup) {
97  $oNewGroup = oxNew("oxobject2group");
98  $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
99  $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
100  $oNewGroup->save();
101  }
102  }
103  }
104 }