discount_users.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00004                                         array( 'oxusername',  'oxuser', 1, 0, 0 ),
00005                                         array( 'oxlname',     'oxuser', 0, 0, 0 ),
00006                                         array( 'oxfname',     'oxuser', 0, 0, 0 ),
00007                                         array( 'oxstreet',    'oxuser', 0, 0, 0 ),
00008                                         array( 'oxstreetnr',  'oxuser', 0, 0, 0 ),
00009                                         array( 'oxcity',      'oxuser', 0, 0, 0 ),
00010                                         array( 'oxzip',       'oxuser', 0, 0, 0 ),
00011                                         array( 'oxfon',       'oxuser', 0, 0, 0 ),
00012                                         array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
00013                                         array( 'oxid',        'oxuser', 0, 0, 1 ),
00014                                         ),
00015                      'container2' => array(
00016                                         array( 'oxusername',  'oxuser', 1, 0, 0 ),
00017                                         array( 'oxlname',     'oxuser', 0, 0, 0 ),
00018                                         array( 'oxfname',     'oxuser', 0, 0, 0 ),
00019                                         array( 'oxstreet',    'oxuser', 0, 0, 0 ),
00020                                         array( 'oxstreetnr',  'oxuser', 0, 0, 0 ),
00021                                         array( 'oxcity',      'oxuser', 0, 0, 0 ),
00022                                         array( 'oxzip',       'oxuser', 0, 0, 0 ),
00023                                         array( 'oxfon',       'oxuser', 0, 0, 0 ),
00024                                         array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
00025                                         array( 'oxid',     'oxobject2discount', 0, 0, 1 ),
00026                                         )
00027                     );
00031 class ajaxComponent extends ajaxListComponent
00032 {
00038     protected function _getQuery()
00039     {
00040         $myConfig = $this->getConfig();
00041 
00042         $sUserTable = getViewName( 'oxuser' );
00043         $sId      = oxConfig::getParameter( 'oxid' );
00044         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00045 
00046         // category selected or not ?
00047         if ( !$sId ) {
00048             $sQAdd = " from $sUserTable where 1 ";
00049             if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00050                 $sQAdd .= " and oxshopid = '".$myConfig->getShopId()."' ";
00051         } else {
00052             // selected group ?
00053             if ( $sSynchId && $sSynchId != $sId ) {
00054                 $sQAdd = " from oxobject2group left join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid where oxobject2group.oxgroupsid = '$sId' ";
00055                 if ( !$myConfig->getConfigParam( 'blMallUsers' ) )
00056                     $sQAdd .= "and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00057 
00058             } else {
00059                 $sQAdd  = " from oxobject2discount, $sUserTable where $sUserTable.oxid=oxobject2discount.oxobjectid ";
00060                 $sQAdd .= " and oxobject2discount.oxdiscountid = '$sId' and oxobject2discount.oxtype = 'oxuser' ";
00061             }
00062         }
00063 
00064         if ( $sSynchId && $sSynchId != $sId ) {
00065             $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from oxobject2discount, $sUserTable where $sUserTable.oxid=oxobject2discount.oxobjectid ";
00066             $sQAdd .= " and oxobject2discount.oxdiscountid = '$sSynchId' and oxobject2discount.oxtype = 'oxuser' ) ";
00067         }
00068 
00069         return $sQAdd;
00070     }
00071 
00077     public function removediscuser()
00078     {
00079         $aRemoveGroups = $this->_getActionIds( 'oxobject2discount.oxid' );
00080         if ( oxConfig::getParameter( 'all' ) ) {
00081 
00082             $sQ = $this->_addFilter( "delete oxobject2discount.* ".$this->_getQuery() );
00083             oxDb::getDb()->Execute( $sQ );
00084 
00085         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00086             $sQ = "delete from oxobject2discount where oxobject2discount.oxid in ('" . implode( "', '", $aRemoveGroups ) . "') ";
00087             oxDb::getDb()->Execute( $sQ );
00088         }
00089     }
00090 
00096     public function adddiscuser()
00097     {
00098         $aChosenUsr = $this->_getActionIds( 'oxuser.oxid' );
00099         $soxId       = oxConfig::getParameter( 'synchoxid');
00100 
00101         if ( oxConfig::getParameter( 'all' ) ) {
00102             $sUserTable = getViewName( 'oxuser' );
00103             $aChosenUsr = $this->_getAll( $this->_addFilter( "select $sUserTable.oxid ".$this->_getQuery() ) );
00104         }
00105         if ( $soxId && $soxId != "-1" && is_array( $aChosenUsr ) ) {
00106             foreach ( $aChosenUsr as $sChosenUsr) {
00107                 $oObject2Discount = oxNew( "oxbase" );
00108                 $oObject2Discount->init( 'oxobject2discount' );
00109                 $oObject2Discount->oxobject2discount__oxdiscountid = new oxField($soxId);
00110                 $oObject2Discount->oxobject2discount__oxobjectid   = new oxField($sChosenUsr);
00111                 $oObject2Discount->oxobject2discount__oxtype       = new oxField("oxuser");
00112                 $oObject2Discount->save();
00113             }
00114         }
00115     }
00116 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5