OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
user_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  $oDb = oxDb::getDb();
36  $sDeldId = oxRegistry::getConfig()->getRequestParameter('oxid');
37  $sSynchDelId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
38 
39  // category selected or not ?
40  if (!$sDeldId) {
41  $sQAdd = " from $sGroupTable where 1 ";
42  } else {
43  $sQAdd = " from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
44  $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sDeldId);
45  }
46 
47  if ($sSynchDelId && $sSynchDelId != $sDeldId) {
48  $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
49  $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sSynchDelId) . " ) ";
50  }
51 
52  return $sQAdd;
53  }
54 
58  public function removeUserFromGroup()
59  {
60  $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
61  if (oxRegistry::getConfig()->getRequestParameter('all')) {
62 
63  $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
64  oxDb::getDb()->Execute($sQ);
65 
66  } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
67  $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
68  oxDb::getDb()->Execute($sQ);
69  }
70  }
71 
75  public function addUserToGroup()
76  {
77  $aAddGroups = $this->_getActionIds('oxgroups.oxid');
78  $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
79 
80  if (oxRegistry::getConfig()->getRequestParameter('all')) {
81  $sGroupTable = $this->_getViewName('oxgroups');
82  $aAddGroups = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
83  }
84  if ($soxId && $soxId != "-1" && is_array($aAddGroups)) {
85  foreach ($aAddGroups as $sAddgroup) {
86  $oNewGroup = oxNew("oxobject2group");
87  $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
88  $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
89  $oNewGroup->save();
90  }
91  }
92  }
93 }