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