OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
user_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( 'oxtitle', 'oxgroups', 1, 0, 0 ),
15  array( 'oxid', 'oxgroups', 0, 0, 0 ),
16  array( 'oxid', 'oxgroups', 0, 0, 1 ),
17  ),
18  'container2' => array(
19  array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
20  array( 'oxid', 'oxgroups', 0, 0, 0 ),
21  array( 'oxid', 'oxobject2group', 0, 0, 1 ),
22  )
23  );
24 
30  protected function _getQuery()
31  {
32  // looking for table/view
33  $sGroupTable = $this->_getViewName('oxgroups');
34  $oDb = oxDb::getDb();
35  $sDeldId = oxConfig::getParameter( 'oxid' );
36  $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
37 
38  // category selected or not ?
39  if ( !$sDeldId) {
40  $sQAdd = " from $sGroupTable where 1 ";
41  } else {
42  $sQAdd = " from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
43  $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sDeldId );
44  }
45 
46  if ( $sSynchDelId && $sSynchDelId != $sDeldId) {
47  $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
48  $sQAdd .= " where oxobject2group.oxobjectid = ".$oDb->quote( $sSynchDelId )." ) ";
49  }
50 
51  return $sQAdd;
52  }
53 
59  public function removeUserFromGroup()
60  {
61  $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
62  if ( oxConfig::getParameter( 'all' ) ) {
63 
64  $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
65  oxDb::getDb()->Execute( $sQ );
66 
67  } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
68  $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
69  oxDb::getDb()->Execute( $sQ );
70  }
71  }
72 
78  public function addUserToGroup()
79  {
80  $aAddGroups = $this->_getActionIds( 'oxgroups.oxid' );
81  $soxId = oxConfig::getParameter( 'synchoxid');
82 
83  if ( oxConfig::getParameter( 'all' ) ) {
84  $sGroupTable = $this->_getViewName('oxgroups');
85  $aAddGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
86  }
87  if ( $soxId && $soxId != "-1" && is_array( $aAddGroups ) ) {
88  foreach ($aAddGroups as $sAddgroup) {
89  $oNewGroup = oxNew( "oxobject2group" );
90  $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
91  $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
92  $oNewGroup->save();
93  }
94  }
95  }
96 }