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