payment_main_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class payment_main_ajax extends ajaxListComponent
00007 {
00013     protected $_aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00014                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00015                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00016                                         array( 'oxid',     'oxgroups', 0, 0, 1 ),
00017                                         ),
00018                                     'container2' => array(
00019                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00020                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00021                                         array( 'oxid',     'oxobject2group', 0, 0, 1 ),
00022                                         )
00023                                 );
00024 
00030     protected function _getQuery()
00031     {
00032         // looking for table/view
00033         $sGroupTable   = $this->_getViewName('oxgroups');
00034         $sGroupId      = $this->getConfig()->getRequestParameter( 'oxid' );
00035         $sSynchGroupId = $this->getConfig()->getRequestParameter( 'synchoxid' );
00036         $oDb = oxDb::getDb();
00037 
00038         // category selected or not ?
00039         if ( !$sGroupId)
00040             $sQAdd  = " from $sGroupTable ";
00041         else {
00042             $sQAdd  = " from $sGroupTable, oxobject2group where ";
00043             $sQAdd .= " oxobject2group.oxobjectid = ".$oDb->quote( $sGroupId )." and oxobject2group.oxgroupsid = $sGroupTable.oxid ";
00044         }
00045 
00046         if ( !$sSynchGroupId )
00047             $sSynchGroupId = $this->getConfig()->getRequestParameter('oxajax_synchfid');
00048         if ( $sSynchGroupId && $sSynchGroupId != $sGroupId) {
00049             if ( !$sGroupId )
00050                 $sQAdd .= 'where ';
00051             else
00052                 $sQAdd .= 'and ';
00053             $sQAdd .= " $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable, oxobject2group where ";
00054             $sQAdd .= " oxobject2group.oxobjectid = ".$oDb->quote( $sSynchGroupId )." and oxobject2group.oxgroupsid = $sGroupTable.oxid ) ";
00055         }
00056 
00057         return $sQAdd;
00058     }
00059 
00065     public function removePayGroup()
00066     {
00067         $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00068         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00069 
00070             $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00071             oxDb::getDb()->Execute( $sQ );
00072 
00073         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00074             $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00075             oxDb::getDb()->Execute( $sQ );
00076         }
00077     }
00078 
00084     public function addPayGroup()
00085     {
00086         $aAddGroups = $this->_getActionIds( 'oxgroups.oxid' );
00087         $soxId      = $this->getConfig()->getRequestParameter( 'synchoxid');
00088 
00089         if ( $this->getConfig()->getRequestParameter( 'all' ) ) {
00090             $sGroupTable   = $this->_getViewName('oxgroups');
00091             $aAddGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00092         }
00093         if ( $soxId && $soxId != "-1" && is_array( $aAddGroups ) ) {
00094             foreach ($aAddGroups as $sAddgroup) {
00095                 $oNewGroup = oxNew( "oxobject2group" );
00096                 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00097                 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00098                 $oNewGroup->save();
00099             }
00100         }
00101     }
00102 }