OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
usergroup_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('oxusername', 'oxuser', 1, 0, 0),
16  array('oxlname', 'oxuser', 0, 0, 0),
17  array('oxfname', 'oxuser', 0, 0, 0),
18  array('oxstreet', 'oxuser', 0, 0, 0),
19  array('oxstreetnr', 'oxuser', 0, 0, 0),
20  array('oxcity', 'oxuser', 0, 0, 0),
21  array('oxzip', 'oxuser', 0, 0, 0),
22  array('oxfon', 'oxuser', 0, 0, 0),
23  array('oxbirthdate', 'oxuser', 0, 0, 0),
24  array('oxid', 'oxuser', 0, 0, 1),
25  ),
26  'container2' => array(
27  array('oxusername', 'oxuser', 1, 0, 0),
28  array('oxlname', 'oxuser', 0, 0, 0),
29  array('oxfname', 'oxuser', 0, 0, 0),
30  array('oxstreet', 'oxuser', 0, 0, 0),
31  array('oxstreetnr', 'oxuser', 0, 0, 0),
32  array('oxcity', 'oxuser', 0, 0, 0),
33  array('oxzip', 'oxuser', 0, 0, 0),
34  array('oxfon', 'oxuser', 0, 0, 0),
35  array('oxbirthdate', 'oxuser', 0, 0, 0),
36  array('oxid', 'oxobject2group', 0, 0, 1),
37  )
38  );
39 
45  protected function _getQuery()
46  {
47  $myConfig = $this->getConfig();
48 
49  // looking for table/view
50  $sUserTable = $this->_getViewName('oxuser');
51  $oDb = oxDb::getDb();
52  $sRoleId = oxRegistry::getConfig()->getRequestParameter('oxid');
53  $sSynchRoleId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
54 
55  // category selected or not ?
56  if (!$sRoleId) {
57  $sQAdd = " from $sUserTable where 1 ";
58  } else {
59  $sQAdd = " from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
60  $sQAdd .= " oxobject2group.oxgroupsid = " . $oDb->quote($sRoleId);
61  }
62 
63  if ($sSynchRoleId && $sSynchRoleId != $sRoleId) {
64  $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
65  $sQAdd .= " oxobject2group.oxgroupsid = " . $oDb->quote($sSynchRoleId);
66  if (!$myConfig->getConfigParam('blMallUsers')) {
67  $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
68  }
69  $sQAdd .= " ) ";
70  }
71 
72  if (!$myConfig->getConfigParam('blMallUsers')) {
73  $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
74  }
75 
76  return $sQAdd;
77  }
78 
82  public function removeUserFromUGroup()
83  {
84  $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
85 
86  if (oxRegistry::getConfig()->getRequestParameter('all')) {
87 
88  $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
89  oxDb::getDb()->Execute($sQ);
90 
91  } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
92  $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
93  oxDb::getDb()->Execute($sQ);
94  }
95  }
96 
100  public function addUserToUGroup()
101  {
102  $aAddUsers = $this->_getActionIds('oxuser.oxid');
103  $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
104 
105  if (oxRegistry::getConfig()->getRequestParameter('all')) {
106  $sUserTable = $this->_getViewName('oxuser');
107  $aAddUsers = $this->_getAll($this->_addFilter("select $sUserTable.oxid " . $this->_getQuery()));
108  }
109  if ($soxId && $soxId != "-1" && is_array($aAddUsers)) {
110  foreach ($aAddUsers as $sAdduser) {
111  $oNewGroup = oxNew("oxobject2group");
112  $oNewGroup->oxobject2group__oxobjectid = new oxField($sAdduser);
113  $oNewGroup->oxobject2group__oxgroupsid = new oxField($soxId);
114  $oNewGroup->save();
115  }
116  }
117  }
118 }